Skip to content

feat(plugins): Add unified plugin registrations#457

Draft
dcramer wants to merge 2 commits into
mainfrom
feat/plugin-registration-overhaul
Draft

feat(plugins): Add unified plugin registrations#457
dcramer wants to merge 2 commits into
mainfrom
feat/plugin-registration-overhaul

Conversation

@dcramer
Copy link
Copy Markdown
Member

@dcramer dcramer commented May 31, 2026

Adds explicit plugin sets as the single enablement gate for Junior plugins. Installing a package is not enough; package content is discovered only when a package name or trusted factory is listed in defineJuniorPlugins(...). Nitro now injects that enabled set through #junior/config, so the server entry no longer repeats the declaration.

Before

Trusted plugins had to split metadata and hooks, and apps had separate build/runtime declarations:

// nitro.config.ts
juniorNitro({
  plugins: {
    packages: ["@sentry/junior-github"],
  },
});
// server.ts
const app = await createApp({
  plugins: [
    githubPlugin({
      botNameEnv: "GITHUB_APP_BOT_NAME",
      botEmailEnv: "GITHUB_APP_BOT_EMAIL",
    }),
  ],
});

The first unification pass made that safer, but still required wiring the same set twice:

// nitro.config.ts
juniorNitro({ plugins });

// server.ts
const app = await createApp({ plugins });

After

Apps export one runtime-safe plugin set and point Nitro at that module. createApp() reads the same enabled set from Nitro's virtual module:

// plugins.ts
export const plugins = defineJuniorPlugins([
  "@sentry/junior-agent-browser",
  "@sentry/junior-datadog",
  githubPlugin({
    botNameEnv: "GITHUB_APP_BOT_NAME",
    botEmailEnv: "GITHUB_APP_BOT_EMAIL",
  }),
  schedulerPlugin(),
  "@sentry/junior-sentry",
]);
// nitro.config.ts
juniorNitro({ plugins: "./plugins" });

// server.ts
const app = await createApp();

Trusted Plugins

GitHub and Scheduler now provide JavaScript registrations with inline manifests and trusted hooks. Manifest-only packages remain package-name strings. The separate plugins.ts module stays intentional because trusted hooks are live functions; importing nitro.config.ts at runtime would pull build config into the server bundle, and serializing hooks is not viable.

junior check, docs, package READMEs, generated API reference, and specs now point users at the explicit defineJuniorPlugins(...) path instead of the removed pluginPackages / plugins.packages shapes. Validated locally with pnpm typecheck, pnpm --filter @sentry/junior test, pnpm docs:check, pnpm skills:check, pnpm release:check, and pnpm --filter @sentry/junior-example exec nitro build.

Fixes GH-453

Let apps define one plugin set and pass it to both Nitro and createApp. Manifest-only plugins use package-name strings, while trusted plugins carry inline manifests and hooks from app code.

Remove split YAML registration for trusted hooks and move GitHub and Scheduler to JavaScript plugin definitions. This keeps trusted runtime behavior explicit without forcing manifest-only packages to write unused code.

Fixes GH-453
Co-Authored-By: GPT-5 Codex <codex@openai.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview, Comment May 31, 2026 5:50pm

Request Review

Comment thread packages/junior/src/chat/plugins/registry.ts
Comment thread packages/junior/src/app.ts Outdated
Let juniorNitro point at a runtime-safe plugin module so apps only declare enabled plugins once. createApp now reads that module through #junior/config while preserving explicit package enablement.

This keeps trusted hook functions available at runtime without importing nitro.config.ts into the server bundle.

Refs GH-453
Co-Authored-By: GPT-5 Codex <codex@openai.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 08f141b. Configure here.

nitro.options.virtual["#junior/config"] = async () => {
if (!options.loadPluginSet) {
return renderVirtualConfig(options);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nitro inline set drops hooks

Medium Severity

Passing a defineJuniorPlugins(...) object directly to juniorNitro({ plugins }) emits a virtual config with catalog JSON and trusted plugin names but leaves pluginSet undefined. createApp() without plugins then loads no trusted registrations while validation still expects names bundled at build time, so boot fails for trusted plugins unless the same set is passed again to createApp.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 08f141b. Configure here.

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.

feat(plugins): reconsider plugin.yaml + pluginInstance() dual-registration complexity

1 participant