Skip to content

A skill to stop your coding agent from burying the answer. ADHD-friendly output.

opencode: make a local checkout load on V2 without config

opencode-agent89ea6c6de1b8
diff --git a/.opencode/plugins/i-have-adhd.js b/.opencode/plugins/i-have-adhd.js
new file mode 100644
index 0000000..df89218
--- /dev/null
+++ b/.opencode/plugins/i-have-adhd.js
@@ -0,0 +1,16 @@
+// OpenCode V2 entry point for i-have-adhd.
+//
+// OpenCode V2 auto-discovers direct `.ts` and `.js` files in a discovered
+// `.opencode/plugins/` directory, but not `.mjs`, and a `plugins` config entry
+// must name a directory — 2.0.18 rejects a file path with "configured plugin
+// path must be a directory" and silently ignores a directory path.
+//
+// This mirror re-exports the implementation so a local checkout works on V2
+// with no config entry. The module keeps its own `__dirname`, so its
+// `../../skills` and `../command/i-have-adhd.md` lookups still resolve inside
+// the checkout.
+//
+// OpenCode V1 does not auto-discover `.opencode/plugins/`, so V1 keeps using
+// the explicit path in `opencode.json`:
+// { "plugin": ["/absolute/path/to/i-have-adhd/.opencode/plugins/i-have-adhd.mjs"] }
+export { default } from './i-have-adhd.mjs';
diff --git a/AGENTS.md b/AGENTS.md
index 9264a71..9e57bda 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -48,7 +48,7 @@ When debugging or changing one integration, begin with its entry point:
| Grok | `plugin.json`, `skills/i-have-adhd/SKILL.md`, `INSTALL.md` |
| Pi | `package.json` (`pi`), `extensions/i-have-adhd.ts` |
| OMP | `package.json` (`omp`), `extensions/i-have-adhd.ts`, `extensions/context-compat.ts` |
-| OpenCode | `opencode.json`, `.opencode/plugins/i-have-adhd.mjs`, `.opencode/command/i-have-adhd.md` |
+| OpenCode | `.opencode/plugins/i-have-adhd.mjs`, `.opencode/plugins/i-have-adhd.js`, `.opencode/command/i-have-adhd.md` |
| Qwen, Kimi, Gemini | The corresponding manifest above, plus `GEMINI.md` for Gemini behavior |
## Source-of-truth rules
diff --git a/INSTALL.md b/INSTALL.md
index 143c9cd..c047f4b 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -548,8 +548,21 @@ This is the recommended global install: two files, no plugin, no build step.
### Plugin (adds always-on)
The plugin registers the skill and the command itself and adds the always-on
-flag. OpenCode V2 loads a plugin that sits in a discovered `.opencode/plugins/`
-directory, so expose the vendored checkout with a one-line loader:
+flag.
+
+**Running from a checkout needs no configuration on OpenCode V2.** V2 auto-discovers
+direct `.ts` and `.js` files in a discovered `.opencode/plugins/` directory, and this
+repository ships `.opencode/plugins/i-have-adhd.js` as a mirror of the implementation.
+Open a terminal in the checkout and start OpenCode.
+
+OpenCode V1 does not auto-discover `.opencode/plugins/`, so add the plugin explicitly:
+
+```jsonc
+{ "plugin": ["/absolute/path/to/i-have-adhd/.opencode/plugins/i-have-adhd.mjs"] }
+```
+
+**For a global install, expose the vendored checkout with a one-line loader**, because
+the checkout is not a discovered project:
```bash
git clone https://github.com/ayghri/i-have-adhd ~/.config/opencode/vendor/i-have-adhd
@@ -561,17 +574,17 @@ EOF
The loader re-exports the vendored module so its `__dirname` — and therefore its
`../../skills` and `../command/i-have-adhd.md` lookups — stay inside the checkout.
-Replace `file://$HOME/...` with an absolute `file:///` URL; a loader is used
-because OpenCode 2.0.18 rejects file paths in `plugins`
-(`configured plugin path must be a directory`) and ignores configured directory
-paths.
+Replace `file://$HOME/...` with an absolute `file:///` URL.
-To run OpenCode from a checkout instead, use the root `opencode.json`, which wires
-the plugin for that directory.
+A `plugins` config entry is not usable for either case on 2.0.18: a file path is
+rejected with `configured plugin path must be a directory`, and a directory path is
+accepted but never loaded. Auto-discovery is the supported route.
## Verify
Start OpenCode, type `/`, and confirm `i-have-adhd` appears in the command list.
+From a checkout on V1, `opencode debug config` should show `command["i-have-adhd"]`
+and the checkout's `skills` directory under `skills.paths`.
## Update
diff --git a/opencode.json b/opencode.json
deleted file mode 100644
index da310cf..0000000
--- a/opencode.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "$schema": "https://opencode.ai/config.json",
- "plugins": ["."]
-}
diff --git a/tests/test_opencode_plugin.py b/tests/test_opencode_plugin.py
index 0594530..d7110b7 100644
--- a/tests/test_opencode_plugin.py
+++ b/tests/test_opencode_plugin.py
@@ -208,5 +208,40 @@ class OpenCodePluginTest(unittest.TestCase):
self.assertEqual([str(self.plugin_root / "skills")], config["skills"]["paths"])
+ # --- V2 auto-discovery mirror ---
+
+ def test_js_mirror_reexports_the_implementation(self):
+ # OpenCode V2 auto-discovers direct .ts/.js files in a discovered
+ # .opencode/plugins/ directory but not .mjs, and a `plugins` config entry
+ # is unusable on 2.0.18 (file paths rejected, directory paths ignored).
+ # The .js mirror is what makes a local checkout load on V2, so assert it
+ # exists and resolves to the same definition as the .mjs.
+ mirror = ROOT / ".opencode" / "plugins" / "i-have-adhd.js"
+ impl = ROOT / ".opencode" / "plugins" / "i-have-adhd.mjs"
+ self.assertTrue(mirror.is_file(), "missing V2 auto-discovery mirror")
+ self.assertTrue(impl.is_file())
+
+ env = os.environ.copy()
+ env["XDG_CONFIG_HOME"] = str(self.config_dir)
+ script = (
+ "const a = (await import(process.argv[1])).default;"
+ "const b = (await import(process.argv[2])).default;"
+ "process.stdout.write(JSON.stringify({"
+ "same: a === b || (a.id === b.id && typeof a.setup === 'function'"
+ " && typeof b.setup === 'function' && typeof a.server === 'function'"
+ " && typeof b.server === 'function'),"
+ "id: a.id, keys: Object.keys(a).sort()}));"
+ )
+ result = subprocess.run(
+ ["node", "--input-type=module", "-e", script, mirror.as_uri(), impl.as_uri()],
+ check=False, capture_output=True, text=True, env=env,
+ )
+ self.assertEqual(0, result.returncode, result.stderr)
+ mirror_export = json.loads(result.stdout)
+ self.assertTrue(mirror_export["same"], "mirror does not re-export the implementation")
+ self.assertEqual("i-have-adhd", mirror_export["id"])
+ self.assertEqual(["id", "server", "setup"], mirror_export["keys"])
+
+
if __name__ == "__main__":
unittest.main()