fix(opencode): stop exporting parseCommandFile from plugin module (#301)

OpenCode's legacy plugin loader iterates every exported function in a
plugin module and tries to invoke each one with the plugin context object.
parseCommandFile was exported alongside the default plugin function, so
the loader called it with an object instead of a file path and crashed
with 'path must be a string or a file descriptor' before any hook ran,
which aborted the whole plugin load.

Move the frontmatter parser to its own .cjs sibling; the plugin module
now exposes exactly one top-level export (the default plugin function).
The plugin requires the parser via createRequire, and the existing
parseCommandFile tests now require the sibling directly.

Co-authored-by: ayushere <ayushere@users.noreply.github.com>
This commit is contained in:
D3VL0PR
2026-07-09 11:44:31 +02:00
committed by GitHub
co-authored by ayushere
parent 8e69b4a55f
commit 511ddd4d62
3 changed files with 29 additions and 10 deletions
+5 -1
View File
@@ -23,7 +23,11 @@ test.before(async () => {
const url = pathToFileURL(path.join(__dirname, '..', '.opencode', 'plugins', 'ponytail.mjs'));
const mod = await import(url);
loadPlugin = mod.default;
parseCommandFile = mod.parseCommandFile;
// The frontmatter parser used to be exported from the plugin module itself.
// OpenCode's legacy loader treats every exported function as a plugin and
// tried to invoke it with the plugin context object, which crashed. The
// parser now lives in its own .cjs sibling; require it directly.
parseCommandFile = require(path.join(__dirname, '..', '.opencode', 'plugins', 'ponytail-frontmatter.cjs')).parseCommandFile;
});
function transform(hooks) {