Skip to content

fix(opencode): move frontmatter parser out of plugins/ directory (#596)#600

Open
prayag0one4 wants to merge 1 commit into
DietrichGebert:mainfrom
prayag0one4:fix/opencode-frontmatter-plugin-scan-596
Open

fix(opencode): move frontmatter parser out of plugins/ directory (#596)#600
prayag0one4 wants to merge 1 commit into
DietrichGebert:mainfrom
prayag0one4:fix/opencode-frontmatter-plugin-scan-596

Conversation

@prayag0one4

Copy link
Copy Markdown

Problem

Loading the ponytail OpenCode plugin (@dietrichgebert/ponytail, installed via "plugin": ["@dietrichgebert/ponytail"]) fails at plugin-load time with:

error="path must be a string or a file descriptor"
error="The \"path\" argument must be of type string or an instance of Buffer or URL. Received an instance of Object"

Root Cause

ponytail-frontmatter.cjs lived inside .opencode/plugins/, which OpenCode's legacy plugin loader scans for modules. It found parseCommandFile exported from that file and tried to call it as a plugin, passing the plugin context object { client: ... } as the filePath argument to fs.readFileSync. This is a recurrence of #301 — the extraction worked for ponytail.mjs exports but the file stayed in the scanned directory.

Fix

Moved ponytail-frontmatter.cjs from .opencode/plugins/ to .opencode/ (outside the scanned directory), updated the two require paths. The plugins/ directory now contains only ponytail.mjs with its single default export.

Verification

  • All 8 OpenCode plugin tests pass
  • Legacy loader simulation shows zero errors — plugins/ only contains the plugin function, nothing else to mistakenly invoke
  • package.json files field uses .opencode/ directory glob, so the moved file is still included in the npm package

Closes #596

Copilot AI review requested due to automatic review settings July 16, 2026 01:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes OpenCode plugin-load failures caused by OpenCode’s legacy plugin loader mistakenly discovering and invoking parseCommandFile as a plugin when it lived under .opencode/plugins/.

Changes:

  • Moved the frontmatter parser module out of .opencode/plugins/ so the legacy loader won’t discover it.
  • Updated the OpenCode plugin module to require() the parser from its new location.
  • Updated tests to import the parser from the new path.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/opencode-plugin.test.js Updates the direct require() path for parseCommandFile to match the parser’s new location.
.opencode/ponytail-frontmatter.cjs Keeps the parser module outside .opencode/plugins/ and updates comments to reflect the loader behavior and incident.
.opencode/plugins/ponytail.mjs Updates the relative require() path so the plugin uses the relocated parser module.

…trichGebert#596)

OpenCode's legacy plugin loader scans .opencode/plugins/ for modules and
treats every exported function as a plugin. ponytail-frontmatter.cjs
lived in that directory and exported parseCommandFile, which the loader
invoked with the plugin context object as its first argument, passing
{ client: ... } to fs.readFileSync. This threw "path must be a string
or a file descriptor" (DietrichGebert#301, DietrichGebert#596).

Move the parser one level up to .opencode/ponytail-frontmatter.cjs, outside
the scanned plugins/ directory. The plugins/ directory now contains only
ponytail.mjs with its single default export.
@prayag0one4
prayag0one4 force-pushed the fix/opencode-frontmatter-plugin-scan-596 branch from b38a8d4 to 655f30c Compare July 16, 2026 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: plugin fails to load in OpenCode with "path must be a string or a file descriptor" / "Received an instance of Object"

2 participants