Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion tests/opencode-plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ test.before(async () => {
parseCommandFile = require(path.join(__dirname, '..', '.opencode', 'plugins', 'ponytail-frontmatter.cjs')).parseCommandFile;
});

test('plugin module exposes only the default export (regression guard for #631, #301)', async () => {
const url = pathToFileURL(path.join(__dirname, '..', '.opencode', 'plugins', 'ponytail.mjs'));
const mod = await import(url);
const namedExports = Object.keys(mod).filter((k) => k !== 'default');
assert.deepEqual(
namedExports,
[],
'ponytail.mjs must not have named exports — OpenCode\'s legacy getLegacyPlugins() ' +
'loader calls every exported function as a plugin factory'
);
});

function transform(hooks) {
const output = { system: [] };
return hooks['experimental.chat.system.transform']({ model: {} }, output).then(() => output.system);
Expand Down Expand Up @@ -101,4 +113,4 @@ test('parseCommandFile returns null when there is no frontmatter', () => {
assert.equal(parseCommandFile(bare), null);
});

test.after(() => fs.rmSync(tmp, { recursive: true, force: true }));
test.after(() => fs.rmSync(tmp, { recursive: true, force: true }));