Skip to content

Make the Ask User Question and Secrets plugins forkable - #4197

Merged
SawyerHood merged 1 commit into
bb/forkable-15-environment-pluginsfrom
bb/forkable-16-interaction-forms
Sep 23, 2026
Merged

SawyerHood merged 1 commit into
bb/forkable-15-environment-pluginsfrom
bb/forkable-16-interaction-forms

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Fourteenth PR in the forkable built-ins stack; it builds on #4196. ask-user-question and secrets render bb's in-thread forms (the pendingInteraction slot). A copy of either couldn't build on its own:

  • Both imported @bb/shared-ui and @bb/plugin-interaction-contracts, a workspace package holding their payload and response schemas.
  • ask-user-question rendered shared-ui's question form, which reaches the host's answer shortcuts through a module only bb plugin build can swap.
  • Their tsconfigs mapped the SDK onto its bundled .d.ts files, and their vitest configs used vitest.shared.ts.

What changed

  • Contracts: each plugin owns its contract (src/contracts.ts, src/secret-request.ts) with its half of the old tests. Nothing else imported @bb/plugin-interaction-contracts, so it is deleted.
  • UI: components come through the registry alias. ask-user-question uses the registry's question-form, whose question-form-host flavor calls experimental_useQuestionFormHost (Expose the question form host through the SDK and the registry #4181), so its engines.bbPluginSdk is >=0.5.22. The built-in bundle still takes the question form host from the app's runtime, so it keeps bb's answer shortcuts and a single React context.
  • Config:
    • The SDK path entries are gone; the package's types condition already points tsc at the same files.
    • ask-user-question's tsconfig maps only @/* and the icon flavor. It never imports question-form-host itself, so it doesn't map it.
    • app.test.tsx and the vitest configs join the tsconfig include.
    • Each plugin declares its test peers and gets a lint script and turbo entries.
  • Stories: ask-user-question's Ladle story rendered through app source, so it moves into apps/app beside the other pending-interaction stories, with origin="plugin" replacing a stale prop. Both stories load their plugin through import.meta.glob (apps/app/.ladle/plugin-app-module.ts), which keeps the plugins' @/ imports out of @bb/app's type program.
  • Docs: docs/forkable-plugins.md records both rules: a listed plugin maps nothing onto @get-bb/plugin-sdk, and Ladle stories load a listed plugin with import.meta.glob.

How you verified

  • pnpm exec turbo run typecheck test lint for both plugins.
  • pnpm check:plugin-forks passes for both. In a kept copy, app.js calls experimental_useQuestionFormHost and never calls createContext.
  • @bb/app typecheck and tests, @bb/scripts, bb-plugin-plugin-api-docs, and the server's built-in plugin tests.
  • Both Ladle stories render in the dev server with no console errors.
  • Bundle identity: app.css is byte-identical. app.js differs only in module paths and in dropping the other plugin's schemas, which the shared package's index had pulled into both bundles. Both bundles take the question form host from runtime.questionFormHost.

🤖 Generated with Claude Code

AGENT GENERATED

@SawyerHood
SawyerHood added this pull request to stack #4182 September 23, 2026 17:22
@SawyerHood
SawyerHood force-pushed the bb/forkable-16-interaction-forms branch from adba3ea to c4072e0 Compare September 23, 2026 17:51
@SawyerHood
SawyerHood force-pushed the bb/forkable-16-interaction-forms branch from c4072e0 to 307d219 Compare September 23, 2026 17:53
@SawyerHood
SawyerHood force-pushed the bb/forkable-16-interaction-forms branch from 307d219 to 06046ab Compare September 23, 2026 20:40
@SawyerHood
SawyerHood marked this pull request as ready for review September 23, 2026 21:07
@SawyerHood
SawyerHood force-pushed the bb/forkable-16-interaction-forms branch from 06046ab to 9511c92 Compare September 23, 2026 21:31
@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
ask-user-question and secrets render bb's in-thread forms, but a copy of
either directory could not build on its own. Both imported @bb/shared-ui
components and @bb/plugin-interaction-contracts, a workspace package
holding their payload and response schemas, and their vitest configs
imported the repository's vitest.shared.ts.

- Each plugin now owns its contract: ask-user-question's schemas join
  src/contracts.ts and secrets' move to src/secret-request.ts, each with
  its half of the old contract tests. Nothing else imported the package,
  so it is gone.
- Components come through the registry alias (@/components/ui/button,
  input, label, and question-form) with thread-list's tsconfig paths.
  The built-in bundle still takes the question form host
  from the app's runtime, so it keeps bb's answer shortcuts and a single
  React context. A copy's registry question form calls
  experimental_useQuestionFormHost, so the plugin's SDK engine range
  moves to 0.5.22.
- The tsconfigs no longer map @get-bb/plugin-sdk onto its bundled
  declarations: with tsconfigPaths, vitest followed those paths at
  runtime and loaded modules with no exports. The package's types
  condition already gives tsc the same files. app.test.tsx and the
  vitest configs join the tsconfig include, and the test's submit mock
  gains the parameter tsc then asked for.
- The fork installs without npm's peer resolution, so each plugin
  declares the SDK test harness peers its tests load.

ask-user-question's Ladle story rendered the plugin through app source,
so it moves into apps/app beside the other pending-interaction stories
and passes origin="plugin", which replaced its stale dismissal prop.
Both stories load their plugin with import.meta.glob, which keeps the
plugins' @/ imports out of @bb/app's type program, and Ladle's Vite
config applies the forkable plugin paths so those imports resolve.
docs/forkable-plugins.md records both rules.

The built app bundles differ from before only in module paths and in
dropping the other plugin's schemas, which the shared package's index
pulled into both. app.css is byte-identical.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@SawyerHood
SawyerHood force-pushed the bb/forkable-16-interaction-forms branch from 9511c92 to 53e7cbd Compare September 23, 2026 22:10
@SawyerHood
SawyerHood merged commit e443d40 into main Sep 23, 2026
23 of 34 checks passed
@SawyerHood
SawyerHood deleted the bb/forkable-16-interaction-forms branch September 23, 2026 22:13
SawyerHood added a commit that referenced this pull request Sep 23, 2026
## Human comments

## What was wrong

Fifteenth PR in the forkable built-ins stack; it builds on #4197. A copy
of `plugins/automations` couldn't install. It imported:

- fourteen `@bb/shared-ui` components;
- shared-ui's automation edit-prompt builder;
- `@bb/domain`'s run-state presentation.

Its own `@/src/rpc-types` alias clashed with the registry alias, and its
tsconfig mapped the SDK onto bundled `.d.ts` files.

The app also typechecked and tested the plugin's views by importing
`bb-plugin-automations/detail-view` and `overview-view`, which pulls the
plugin's `@/` imports into `@bb/app`'s type program. Two Ladle stories
did the same.

## What changed

- **Imports:** components come through the registry alias, and the
plugin's own `@/` import becomes relative.
- **Moved into the plugin:** the run-state labels and icons
(`detail-view.tsx`) and the edit-prompt builder (`lib/edit-prompt.ts`,
with its test), which only the plugin used. shared-ui drops
`buildAutomationEditThreadPrompt`, and `@bb/domain` drops
`RUN_STATE_PRESENTATION`; its only other reader was
`UPDATE_STATE_PRESENTATION`'s three icon names, now written out.
- **Config:**
  - The SDK path entries are gone.
- The tsconfig `include` names every root module that imports `@/`,
because Vite applies tsconfig paths only to included files. The fork
check caught this; the in-repo run did not. It also includes
`automations.stories.tsx`, so tsc checks the story.
  - Tests use `defineConfig` and declare their peers.
- The package drops `@bb/domain` and the `exports` map only the app
used.
- **Tests:** the app's two automation view tests move into the plugin
and render through the SDK test runtime. Their one host assertion, that
a registered provider icon replaces the caller's fallback, moves to a
new `ProviderIcon.test.tsx` case in `apps/app`.
- **Stories:**
- The Ladle stories move to
`plugins/automations/automations.stories.tsx`. The story imports nothing
outside the plugin: it lays out its own rows, and it requests the model
picker catalog through its Ladle `meta` (`modelPickerCatalog`).
- Ladle's global provider reads that meta and wraps the story in the
app's `ModelPickerStoryQueryProvider`.
  - `apps/app` no longer depends on the plugin.
- **frontend-imports test:** `frontend-imports.test.ts` keeps zod out of
the app bundle, and it now resolves `@/` through the plugin's own
tsconfig, so it runs in a copy.
- **Lint:**
- A comment in startup reconciliation becomes a pending-thread case in
its test.
  - A deliberate field-level dependency list is marked for the linter.
- **Docs:** `docs/forkable-plugins.md` adds the `include` rule, that
tests of a plugin's own components live in the plugin, and how a
plugin-hosted Ladle story asks for app data through its `meta`.

## How you verified

- `pnpm exec turbo run typecheck test lint
--filter=bb-plugin-automations`; `@bb/domain`, `@bb/shared-ui`, and
`@bb/scripts`; `@bb/app` and `@bb/integration-tests` typecheck; the
legacy automations round-trip integration test.
- `pnpm check:plugin-forks plugins/automations` passes in a copy.
- All five Automations stories render in the Ladle dev server with no
errors, showing the host model picker's labels.
- **Mutation checks:** treating `pending` like `error` fails the new
reconcile case, and changing `ProviderIcon`'s `name={glyph ?? fallback}`
to `name={glyph ?? "Code"}` fails the new fallback case.
- **Bundle identity:** `app.css` is byte-identical; `app.js` drops the
unused update-state table.

🤖 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