Skip to content

feat(opencode): discover plugin package directories under plugins/#33391

Open
licat2023 wants to merge 2 commits into
anomalyco:devfrom
licat2023:plugin-dir-discovery
Open

feat(opencode): discover plugin package directories under plugins/#33391
licat2023 wants to merge 2 commits into
anomalyco:devfrom
licat2023:plugin-dir-discovery

Conversation

@licat2023

Copy link
Copy Markdown

Issue for this PR

Closes #33390

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

A local plugin listed in opencode.jsonc can point at a directory (one holding a package.json or an index.*) and resolves fine. But the zero-config plugins/ folder only scanned {plugin,plugins}/*.{ts,js}, so directory-style plugins were silently never discovered — you had to declare them in config.

This adds a second glob, {plugin,plugins}/*/{package.json,index.*}, and emits the directory URL (not the index file). The existing resolvePluginEntrypoint then resolves the real entrypoint via exports/main/index — the same path a config-declared directory plugin already takes, so there is no new resolution logic. The single * keeps it depth-1, so a package's own src/ or node_modules/ are never mistaken for plugins. INDEX_FILES is exported from plugin/shared.ts so detection and resolution share one list.

How did you verify your code works?

  • bun typecheck in packages/opencode passes.
  • Manual: dropped plugins/demo/ (a package.json with exports["./server"] + entrypoint) alongside a flat plugins/single.ts; both load and show up in the status dialog. A bare folder with no package.json/index.* is correctly ignored.

Screenshots / recordings

N/A — no UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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.

[FEATURE]: plugins/ folder only auto-discovers flat files, not plugin directories

1 participant