Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .opencode/plugins/ponytail.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
const require = createRequire(import.meta.url);
const { getPonytailInstructions } = require('../../hooks/ponytail-instructions');
const { getDefaultMode, normalizePersistedMode } = require('../../hooks/ponytail-config');
const { parseCommandFile } = require('./ponytail-frontmatter.cjs');
const { parseCommandFile } = require('../ponytail-frontmatter.cjs');

// OpenCode has no flag-file convention of its own; keep mode beside its config.
const statePath = path.join(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

// ponytail command-file frontmatter parser.
//
// Pulled out of ponytail.mjs so the plugin module's only top-level export is
// the plugin function itself. OpenCode's legacy plugin loader (the one that
// runs before v1 plugins are detected) treats every function exported from a
// plugin module as a plugin; calling the frontmatter parser as one threw
// "path must be a string or a file descriptor" because it got the plugin
// context object as its first argument. Keeping the parser in its own module
// leaves exactly one plugin-shaped export on ponytail.mjs.
// Lives outside .opencode/plugins/ so OpenCode's legacy plugin loader
// doesn't discover it. The legacy loader treats every exported function
// from any file under plugins/ as a plugin; calling parseCommandFile with
// the plugin context object threw "path must be a string or a file
// descriptor" (#301, #596).

function parseCommandFile(filePath) {
const fs = require('fs');
Expand Down
2 changes: 1 addition & 1 deletion tests/opencode-plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test.before(async () => {
// 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;
parseCommandFile = require(path.join(__dirname, '..', '.opencode', 'ponytail-frontmatter.cjs')).parseCommandFile;
});

function transform(hooks) {
Expand Down