Skip to content

Harden the plugin fork check for more built-ins - #4178

Merged
SawyerHood merged 1 commit into
mainfrom
bb/forkable-01-fork-check
Sep 23, 2026
Merged

SawyerHood merged 1 commit into
mainfrom
bb/forkable-01-fork-check

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

First PR in a stack that makes bb's other built-in plugins forkable, the way #4140 did for the sidebar. Auditing the other 36 built-ins against pnpm check:plugin-forks showed gaps in the machinery itself that every one of them hits after thread-list:

  • SDK host entries fail under plain Node. The published @get-bb/plugin-sdk/host and /provider-bridge entries inlined cross-spawn. cross-spawn is CommonJS that requires Node builtins, so importing either entry outside a bundler threw Dynamic require of "child_process" is not supported. A plugin's own host.test.ts does exactly that once it installs the SDK from npm.
  • Registry versions come from the app manifest only. The fork check read registry package versions from apps/app/package.json alone, so items the app doesn't depend on directly (collapsible, tabs, label, radio-group, cmdk) aborted the check.
  • The lint rule only rejects @bb/*. bb/forkable-plugin-imports let through workspace packages without the scope, such as bb-environment-provider-host, and the SDK's internal/* modules, which bb can change in any release.
  • The check can't scale. It ran plugins one at a time and stopped at the first failure, which won't fit the CI job's 20-minute budget once dozens of plugins are listed.

What changed

  • SDK 0.5.21: cross-spawn stays external. It becomes a dependency of the package, so dist/host.js and dist/provider-bridge.js import it the way Node loads CommonJS. The entry list and esbuild options move from build-runtime.mjs to scripts/runtime-entries.mjs so a test can build the entries and import them. plugin-build's zod-resolution test simulates an npm install of the SDK, and it now copies the SDK's dependencies too.
  • Fork check versions: registry package versions come from packages/plugin-registry/package.json, and the app's pinned versions win where the app declares one.
  • Fork check concurrency: --concurrency=<n>, default up to 4. It prints Checking <plugin> … when each plugin starts, so a hung step still shows which plugin it was in, and the plugin's steps when it finishes. All failures are reported at the end.
  • Lint rule: rejects imports of every workspace package (apps, packages, plugins, tests, examples) except @get-bb/plugin-sdk. It also rejects the SDK's internal/* modules.
  • Turbo: prepare:bundled lists packages/plugin-registry/flavors/** as an input, so a change to the host-backed icon rebuilds forkable plugins' bundles.
  • Docs: docs/forkable-plugins.md describes the list, the checks, and what a listed plugin looks like: registry alias, its own vitest config, declared test peers, portable tests, turbo entries, names unchanged from the built-in, and engines.bbPluginSdk as the SDK floor. The thread-list doc links to it.

No wire changes.

How you verified

  • New runtime-entries.test.mjs: builds every published entry. It asserts that none inlines a CommonJS require shim, that every external is a dependency or peer, and that ./host and ./provider-bridge import under plain Node. Against the old externals list, 3 of its 4 tests fail with the Dynamic require error.
  • Lint rule: new plugin-forks.test.mjs cases reject bb-environment-provider-host/git, bb-plugin-tasks, and @get-bb/plugin-sdk/internal/plugin-app-collector, and still allow the SDK's public entries (/host, /testing/app) and npm packages. The internal/ case fails without the new check.
  • Turbo: pnpm exec turbo run build build:types typecheck test lint --filter=@get-bb/plugin-sdk --filter=@bb/scripts --filter=bb-plugin-thread-list, plus the tests for @bb/plugin-build, @bb/templates, and @bb/cli.
  • Fork check: pnpm check:plugin-forks passes for thread-list.
  • SDK version guards: node .github/workflows/check-plugin-sdk-version.mjs and node packages/plugin-sdk/scripts/check-npm-version-guard.mjs.

🤖 Generated with Claude Code

AGENT GENERATED

@SawyerHood
SawyerHood added this pull request to stack #4182 September 23, 2026 16:34
@SawyerHood
SawyerHood force-pushed the bb/forkable-01-fork-check branch from 9bfd804 to 5d929e8 Compare September 23, 2026 16:36
@SawyerHood SawyerHood changed the title bb/forkable 01 fork check Harden the plugin fork check for more built-ins Sep 23, 2026
@SawyerHood
SawyerHood force-pushed the bb/forkable-01-fork-check branch from 5d929e8 to 8824a26 Compare September 23, 2026 16:47
@SawyerHood
SawyerHood force-pushed the bb/forkable-01-fork-check branch 2 times, most recently from b8f73f7 to a5cc98e Compare September 23, 2026 20:40
@SawyerHood
SawyerHood marked this pull request as ready for review September 23, 2026 21:07
@SawyerHood
SawyerHood removed this pull request from stack #4182 September 23, 2026 21:40
@SawyerHood
SawyerHood added this pull request to stack #4220 September 23, 2026 21:41
The fork check and the published SDK had gaps that every built-in
plugin after thread-list hits:

- The SDK's `host` and `provider-bridge` entries inlined cross-spawn,
  CommonJS that requires Node builtins, so importing them under plain
  Node threw "Dynamic require of child_process". A plugin's own host
  tests do exactly that once it installs the SDK from npm. cross-spawn
  now stays external and is a dependency of the package. The entry list
  and esbuild options move to scripts/runtime-entries.mjs so a test can
  build and import them, and plugin-build's simulated SDK install copies
  the SDK's dependencies the way npm does. SDK 0.5.21.
- The fork check took registry package versions from the app manifest
  only, so items the app does not depend on directly (collapsible, tabs,
  label, radio-group, cmdk) failed. It now reads the registry package's
  own manifest first.
- The lint rule caught `@bb/*` imports only; `bb-environment-provider-host`
  and other workspace packages without the scope passed. It now rejects
  every workspace package except the SDK, and the SDK's internal/*
  modules, which bb can change in any release.
- `prepare:bundled` did not list the registry's plugin flavors as
  inputs, so changing the host-backed icon left forkable plugins'
  bundles cached.

The fork check also runs plugins concurrently (default up to 4) and
reports every failure instead of stopping at the first, so the CI job
stays inside its timeout as the list grows. It prints a line when each
plugin starts and the plugin's steps when it finishes.
docs/forkable-plugins.md describes what a listed plugin looks like.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@SawyerHood
SawyerHood force-pushed the bb/forkable-01-fork-check branch from a5cc98e to 70df93e Compare September 23, 2026 22:10
@SawyerHood
SawyerHood merged commit 9158444 into main Sep 23, 2026
18 checks passed
@SawyerHood
SawyerHood deleted the bb/forkable-01-fork-check branch September 23, 2026 22:13
SawyerHood added a commit that referenced this pull request Sep 23, 2026
…ms (#4179)

## Human comments

## What was wrong

Second PR in the forkable built-ins stack; it builds on #4178. Built-in
plugins import nine shared-ui components that the component registry
doesn't provide, so a fork can't write them into its copy:

- activity-row-styles
- branch-picker-primitives
- coarse-pointer-visibility
- delayed-loading
- option-display
- plugin-icon
- resource-list
- resource-pagination
- workflow-progress

The app uses each of them too, so they belong in the registry rather
than in plugin copies.

The generator had a second problem: it flattened every `components/ui`
file to `components/ui/<basename>` and named the item after the bare
basename. resource-list re-exports seven files under
`components/ui/resource/`. Flattened, their relative imports broke, and
they would have been published as items named `row`, `toolbar`, and
`atoms`.

## What changed

- `registry.json` lists the nine components. Their import closures add
`resource-route-label` and the seven `resource-*` files.
- `build-registry.mjs` keeps a component's subdirectory in its target,
so `components/ui/resource/row.tsx` stays at that path. The item name
carries the directory: `resource-row`, `resource-toolbar`, and so on. No
existing item changes.

## How you verified

- `vendor-all-items.test.ts` vendors every item into one plugin and runs
`bb plugin build`. With the old flattened targets it fails (`Could not
resolve "./resource/atoms"`); with this change it passes.
- `pnpm exec turbo run typecheck test --filter=@bb/plugin-registry`,
which includes `build-registry.mjs --check`.
- The `plugin-forks.test.mjs` suite passes against the new items.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> AGENT GENERATED
SawyerHood added a commit that referenced this pull request Sep 23, 2026
## Human comments

## What was wrong

Third PR in the forkable built-ins stack; it builds on #4179. Seven
built-ins import no workspace package, but a copy of each still failed
`pnpm check:plugin-forks`:

- custom-instructions
- drafts
- environment-personal-workspace
- pdf-preview
- plugin-api-tester
- provider-retry
- push-notifications

The failures:

- **Shared vitest config.** Their `vitest.config.ts` imported the
repository's `vitest.shared.ts`.
- **Missing test peers.** The fork installs with `--legacy-peer-deps`,
so the SDK test harness's optional peers never arrive:
- `createFakePluginHost` loads `better-sqlite3`, `cron-parser`, and
`hono`.
- `renderSlot` needs `@testing-library/dom`. Without it,
`@testing-library/react`'s types lose `waitFor`, `fireEvent`, and every
query on `RenderedSlot`.

## What changed

- **Test config:** each plugin's vitest config uses `defineConfig`, and
each declares the dev dependencies its tests load.
- **Lint scripts:** each plugin gets a `lint` script, so the forkable
import rule runs on it. That surfaced two things:
  - code comments in provider-retry, now removed;
- a deliberate field-level dependency list in pdf-preview's `useMemo`,
now marked for the linter instead of changed.
- **Removed test:** push-notifications' `public-sdk-only.test.ts` is
gone. The lint rule and the fork check enforce the same boundary, and
its assertion that `@bb/plugin-build` is a dev dependency fails in a
copy, which drops it.
- **SDK types:** push-notifications' tsconfig no longer maps
`@get-bb/plugin-sdk` onto the repository's bundled declarations, a path
a copy doesn't have. The package's `types` condition already names them.
- **Cleanup:** drafts drops an unused `@bb/shared-ui` dependency.
- **Turbo:** each plugin's `test` task depends on
`@get-bb/plugin-sdk#build`, because vitest now resolves the SDK's built
entries.
- **List:** all seven go into `scripts/forkable-plugins.json`.

Behavior for users is unchanged; the built-ins' names are unchanged.

## How you verified

- `pnpm exec turbo run typecheck test lint` for the seven plugins,
including push-notifications' typecheck without the path mapping.
- `pnpm check:plugin-forks`: all eight listed plugins install,
typecheck, test, and `bb plugin build` in a copy, including
environment-personal-workspace's host tests, which fail before #4178.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> AGENT GENERATED
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.

1 participant