The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.
JavaScript agent-skillsai-agentautomationbrowserbrowser-automationclaude-codecodexhermes-agentskillsskills-sh
fix(plugins): load the OpenCode adapter on OpenCode 2 too
0x06d7a5f1e0598
diff --git a/plugins/ego/README.md b/plugins/ego/README.mdindex 75b5d99..7b7145b 100644--- a/plugins/ego/README.md+++ b/plugins/ego/README.md@@ -235,8 +235,12 @@ artifact. See the [QwenWork expert-kit guide](https://qwenwork.cn/docs/desktop/e### OpenCode-Extract the local npm archive into a persistent directory, then register the-extracted package directory:+The package works with OpenCode 1 and OpenCode 2, which ships as+`@opencode/cli`. Run `opencode --version` to see which one is installed; the+two install plugins differently.++On OpenCode 1, extract the local npm archive into a persistent directory, then+register the extracted package directory:```bashmkdir -p /absolute/path/to/ego-opencode@@ -246,15 +250,31 @@ opencode plugin /absolute/path/to/ego-opencode/package -gKeep the extracted directory in place. OpenCode does not install the `.tgz`itself. Once the package is published, install it by name instead:-`opencode plugin @citrolabs/ego-opencode -g`.+`opencode plugin @citrolabs/ego-opencode -g`. To remove the plugin, delete its+entry from the `plugin` array of the applicable `opencode.json` or+`opencode.jsonc`.-The package is named `@citrolabs/ego-opencode`. Its `.` and `./server` exports-load `index.js`, which adds the packaged `skills/` directory to OpenCode's-Skill paths. OpenCode then lists ego-browser as a Skill and offers it as the-`/ego-browser` command. To remove the plugin, delete its entry from the-`plugin` array of the applicable `opencode.json` or `opencode.jsonc`.+On OpenCode 2, `opencode plugin add` accepts only npm and Git packages. Once the+package is published, install it with:-See the [OpenCode plugin guide](https://opencode.ai/docs/plugins/).+```bash+opencode plugin add @citrolabs/ego-opencode+```++Remove it with `opencode plugin remove @citrolabs/ego-opencode`. To try the+local archive first, extract it as above, then add the absolute path of the+extracted `package` directory to the `plugins` array of `opencode.json` in the+folder that `opencode debug paths config` prints.++The package is named `@citrolabs/ego-opencode`. Its `.` and `./server` exports+load `index.js`, whose default export serves both versions. OpenCode 1 calls+`server()`, which adds the packaged `skills/` directory to its Skill paths and+offers ego-browser as the `/ego-browser` command. OpenCode 2 calls `setup()`,+which adds the packaged ego-browser Skill unless the user already has one, such+as the copy ego lite installs in `~/.agents/skills`.++See the plugin guides for [OpenCode 1](https://opencode.ai/docs/plugins/) and+[OpenCode 2](https://opencode.ai/v2/docs/build/plugins/).### DeepSeek Harnessdiff --git a/plugins/ego/index.js b/plugins/ego/index.jsindex c9b8d95..1ce32f3 100644--- a/plugins/ego/index.js+++ b/plugins/ego/index.js@@ -1,15 +1,46 @@+import { readFile } from "node:fs/promises";import { fileURLToPath } from "node:url";const skillsPath = fileURLToPath(new URL("./skills", import.meta.url));+const skillFile = fileURLToPath(+ new URL("./skills/ego-browser/SKILL.md", import.meta.url),+);-export const EgoBrowserPlugin = async () => ({- config: async (config) => {- // OpenCode hands plugins its normalized config, which keeps extra Skill- // folders in skills.paths. Each discovered Skill also becomes a command.- config.skills ??= {};- config.skills.paths ??= [];- if (!config.skills.paths.includes(skillsPath)) {- config.skills.paths.push(skillsPath);- }+// OpenCode 1 calls server() and OpenCode 2 calls setup(); each ignores the+// other, so one default export serves both.+export default {+ id: "citrolabs.ego",+ async server() {+ return {+ config: async (config) => {+ // OpenCode hands plugins its normalized config, which keeps extra Skill+ // folders in skills.paths. Each discovered Skill also becomes a command.+ config.skills ??= {};+ config.skills.paths ??= [];+ if (!config.skills.paths.includes(skillsPath)) {+ config.skills.paths.push(skillsPath);+ }+ },+ };},-});+ async setup(ctx) {+ // OpenCode 2 plugins add Skills one at a time. Shape it the way OpenCode+ // reads a Skill folder, and let a Skill the user already has win.+ const markdown = await readFile(skillFile, "utf8");+ const [, frontMatter, content] = markdown.match(+ /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/,+ );+ const field = (key) =>+ frontMatter.match(new RegExp(`^${key}: (.+)$`, "m"))[1].trim();+ const skill = {+ id: "ego-browser",+ name: field("name"),+ description: field("description"),+ path: skillFile,+ content,+ };+ await ctx.skill.transform((editor) => {+ if (!editor.get(skill.id)) editor.add(skill);+ });+ },+};diff --git a/plugins/ego/tests/cross-host-plugin.test.mjs b/plugins/ego/tests/cross-host-plugin.test.mjsindex 46e1c4f..821490e 100644--- a/plugins/ego/tests/cross-host-plugin.test.mjs+++ b/plugins/ego/tests/cross-host-plugin.test.mjs@@ -246,7 +246,7 @@ test("Codex listing metadata satisfies the plugin directory", () => {}});-test("OpenCode adapter registers only the packaged Skill path", async () => {+test("OpenCode adapter registers only the packaged Skill", async () => {const pkgSource = read(`${pluginRoot}/package.json`);const pkg = JSON.parse(pkgSource);assert.equal(pkg.name, "@citrolabs/ego");@@ -259,10 +259,17 @@ test("OpenCode adapter registers only the packaged Skill path", async () => {assertPureSkillText(pkgSource, "npm package metadata");const adapterSource = read(`${pluginRoot}/index.js`);- const { EgoBrowserPlugin } = await import(+ const { default: plugin } = await import(new URL(`../../../${pluginRoot}/index.js`, import.meta.url));- const hooks = await EgoBrowserPlugin({});+ // OpenCode 1 reads id and server(), and rejects a default export that also+ // has tui(). OpenCode 2 reads id and setup().+ assert.equal(typeof plugin.id, "string");+ assert.equal(typeof plugin.server, "function");+ assert.equal(typeof plugin.setup, "function");+ assert.equal(plugin.tui, undefined);++ const hooks = await plugin.server({});const config = {};await hooks.config(config);await hooks.config(config);@@ -289,6 +296,48 @@ test("OpenCode adapter registers only the packaged Skill path", async () => {paths: ["/user/skills", config.skills.paths[0]],urls: [],});++ const skills = new Map();+ const ctx = {+ skill: {+ transform: async (edit) =>+ edit({+ get: (id) => skills.get(id),+ add: (skill) => skills.set(skill.id, skill),+ }),+ },+ };+ await plugin.setup(ctx);+ const skill = skills.get("ego-browser");+ const skillText = read(`${pluginRoot}/skills/ego-browser/SKILL.md`);+ assert.deepEqual(Object.keys(skill), [+ "id",+ "name",+ "description",+ "path",+ "content",+ ]);+ assert.equal(skill.name, "ego-browser");+ assert.match(skill.path, /plugins\/ego\/skills\/ego-browser\/SKILL\.md$/);+ // OpenCode 2 stores the Skill body without its front matter.+ assert.equal(+ skill.content,+ skillText.slice(skillText.indexOf("\n---\n") + "\n---\n".length),+ );+ assert.ok(skillText.includes(`\ndescription: ${skill.description}\n`));+ assert.doesNotMatch(+ skill.description,+ /^[>|"']/,+ "the adapter reads a plain one-line description",+ );++ skills.set("ego-browser", { id: "ego-browser", path: "/user/SKILL.md" });+ await plugin.setup(ctx);+ assert.equal(+ skills.get("ego-browser").path,+ "/user/SKILL.md",+ "a Skill the user already has keeps priority",+ );assertPureSkillText(adapterSource, "OpenCode adapter");});@@ -394,6 +443,7 @@ test("plugin README documents every host as a pure-Skill install", () => {assert.match(readme, /\.codebuddy-plugin\/plugin\.json/);assert.match(readme, /\.qoder-plugin\/plugin\.json/);assert.match(readme, /opencode plugin \/absolute\/path/);+ assert.match(readme, /opencode plugin add @citrolabs\/ego-opencode/);assert.match(readme, /dsh plugin --profile web add \/absolute\/path/);assert.match(readme, /pi install npm:@citrolabs\/ego-pi/);assert.match(diff --git a/plugins/ego/tests/plugin-packaging.test.mjs b/plugins/ego/tests/plugin-packaging.test.mjsindex 0d7dc29..7ebf0e4 100644--- a/plugins/ego/tests/plugin-packaging.test.mjs+++ b/plugins/ego/tests/plugin-packaging.test.mjs@@ -354,10 +354,14 @@ function assertArtifacts(root, output, name, version, skillName) {import assert from 'node:assert/strict';import { existsSync } from 'node:fs';import { join } from 'node:path';- import { EgoBrowserPlugin } from '@citrolabs/ego-opencode/server';+ import plugin from '@citrolabs/ego-opencode/server';const config = {};- await (await EgoBrowserPlugin()).config(config);+ await (await plugin.server()).config(config);assert.ok(existsSync(join(config.skills.paths[0], 'ego-browser', 'SKILL.md')));+ const added = [];+ await plugin.setup({ skill: { transform: async (edit) => edit({ get() {}, add: (skill) => added.push(skill) }) } });+ assert.equal(added.length, 1);+ assert.ok(existsSync(added[0].path));`,],{ cwd: packages.get("opencode"), encoding: "utf8" },