Repository navigation
Stop committing generated modules; turbo generates them - #1943
Conversation
|
🚨 SLOP COP 🚨 · I am SlopCop. I am reviewing this pull request now. I will check security, code quality, performance, architecture, and the end-to-end build path. |
The prompt templates, the plugin SDK bundled .d.ts, the scaffold embeds, the plugin theme CSS and the runtime export manifest were committed derivatives of tracked sources. They are large single-line blobs that merge-conflict on almost every concurrent change (216, 154 and 149 commits in three months for the top three). They are now gitignored and produced by turbo tasks with explicit inputs/outputs: @bb/templates#generate:templates, @bb/templates#generate:plugin-scaffold, @bb/plugin-build#generate and @get-bb/plugin-sdk#build:types. `topo` depends on the cheap generators so every build/typecheck/test task is ordered after them; only real consumers depend on the 20s dts bundle. All --check modes, staleness tests and ad-hoc generator calls in build scripts are removed. Co-Authored-By: Claude <[email protected]>
f99d7ba to
c3ce10f
Compare
| "inputs": [ | ||
| "$TURBO_DEFAULT$", | ||
| "$TURBO_ROOT$/packages/*/package.json", | ||
| "$TURBO_ROOT$/packages/*/src/**", |
There was a problem hiding this comment.
🚨 slopcop/review — [P1] Include the shared TypeScript configuration in this task's inputs. packages/plugin-sdk/tsconfig.json extends that configuration, and rollup-plugin-dts consumes it. A shared configuration change can alter declarations without changing this cache key, so Turbo can restore stale output. This broad glob also hashes five ignored generated modules, including downstream scaffold output. Narrow the source inputs and add packages/tsconfig/*.json.
There was a problem hiding this comment.
Fixed in 50ecc2f: @get-bb/plugin-sdk#build:types (and #build) now hash $TURBO_ROOT$/packages/tsconfig/*.json and exclude packages/*/src/generated/** from the source glob.
| "node": ">=22.19.0" | ||
| }, | ||
| "scripts": { | ||
| "prepare": "turbo run generate:templates generate --filter=@bb/templates --filter=@bb/plugin-build --output-logs=errors-only --summarize=false", |
There was a problem hiding this comment.
🚨 slopcop/review — [P2] This hook creates only the cheap source outputs. It leaves packages/plugin-sdk/bundled-types absent, although package exports and plugin TypeScript paths reference that ignored directory. A fresh install therefore leaves editor imports unresolved until a specific Turbo consumer runs. Add an editor preparation path or another fast fallback for these declarations.
There was a problem hiding this comment.
Partly addressed in 50ecc2f. The SDK declarations are no longer needed by the CLI build at all: syncPluginTypes reads packages/plugin-sdk/bundled-types at runtime in dev (the packaged CLI inlines them at bundle time), so bb plugin new and every other pnpm bb path work on a fresh install. What remains is editor resolution of @get-bb/plugin-sdk inside plugins/* before the first typecheck. I did not add the ~20 s rollup build to prepare on purpose (it would run on every pnpm install); AGENTS.md now documents the one-off command. Open to adding it to prepare if the install-time cost is acceptable.
| if (current === content) { | ||
| console.log(`Unchanged ${path.relative(pkgRoot, target)}`); | ||
| } else { | ||
| writeFileSync(target, content); |
There was a problem hiding this comment.
🚨 slopcop/review — [P2] Write these generated declarations with a temporary sibling and an atomic rename. Independent Turbo processes can run this task and a consumer at the same time. writeFileSync truncates the final file before it replaces the content, so another process can read a partial declaration. Apply the same fix to generate-plugin-theme.mjs, which also writes its final output directly.
There was a problem hiding this comment.
Fixed in 50ecc2f: both build-bundled-dts.mjs and generate-plugin-theme.mjs now write a temp sibling and rename (the templates generators already did).
| "dependsOn": [ | ||
| "^topo" | ||
| "^topo", | ||
| "@bb/templates#generate:templates", |
There was a problem hiding this comment.
🚨 slopcop/review — [P2] Do not attach both global generators to every topo node. The dry graph contains 69 topo tasks, and each one depends on these generators. A prompt, SDK, or shared UI change can therefore invalidate unrelated build, test, and type-check caches. Add generator edges only to actual consumers, or split the transit nodes by generated output.
There was a problem hiding this comment.
Fixed in 50ecc2f: the generator edges moved from the global topo to @bb/templates#topo and @bb/plugin-build#topo. Only packages that transitively depend on those two packages (i.e. can resolve the generated sources) are ordered after the generators; @bb/domain#typecheck etc. no longer depend on them (verified with turbo --dry=json).
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain English summary: This PR stops storing large generated modules in Git. Turbo now creates them when a task needs them. The approach reduces merge conflicts, but the new task graph has four cache and file-write problems.
I found four issues:
- High: The SDK declaration cache omits shared TypeScript configuration. Turbo can restore stale declarations after a configuration change. Its broad source glob also hashes five downstream generated files and causes extra rebuilds.
- Medium: A fresh
pnpm installdoes not create the ignored SDK declarations. Editors can report unresolved plugin SDK imports until a specific Turbo task runs. - Medium: Two generators write final files directly. Concurrent Turbo processes can read a declaration or theme module while another process rewrites it.
- Medium: All 69
topotasks depend on both global generators. A prompt, SDK, or shared UI change can invalidate unrelated build, test, and type-check caches.
The generated declarations match the former committed files. The other generated modules only change their source comments. Six affected package type checks passed. The CLI, server, and host daemon builds passed. The application and Settings page loaded without browser console errors.
The plugin SDK and template tests passed. One unchanged plugin CSS test failed twice. The test source and generated theme match the parent commit, so I did not attribute that failure to this PR.
The generator split is reasonable. The architecture can improve by adding edges only to real consumers and by sharing the existing atomic-write pattern. The existing duplicated shim list remains a drift risk, but this PR does not increase that duplication.
This run reviewed f99d7ba9. The PR advanced during the review, but the newer revision did not change the four affected files.
- The plugin-SDK declarations are no longer embedded in a generated module. `syncPluginTypes` loads them at runtime: the packaged CLI (host-daemon/dist/bb) inlines them through an esbuild `define` at bundle time; source and dev builds read packages/plugin-sdk/ bundled-types from the workspace. `@bb/cli#build` (every `pnpm bb`) no longer waits for the 20s rollup dts build, which timed out the source-CLI wrapper test on CI. - Generator edges hang off `@bb/templates#topo` / `@bb/plugin-build#topo` instead of every package's `topo`, so a prompt or theme change no longer invalidates unrelated caches. - `@get-bb/plugin-sdk#build:types` hashes packages/tsconfig/*.json and excludes generated modules from its source glob. - build-bundled-dts.mjs and generate-plugin-theme.mjs write through a temp sibling + rename. Co-Authored-By: Claude <[email protected]>
…ow bridge Resolves two conflicts against upstream: - packages/templates/src/generated/templates.generated.ts: upstream stopped committing generated modules (get-bb#1943); take the deletion, turbo regenerates it. - plugins/memory/app.tsx: keep this branch's Pick<MemoryRecordContract> alias and hand-rolled parsers. Upstream's PluginRpcResult alias would redeclare MemoryRecord, and the merged-in candidate parsers depend on isRecord/parseMemory.
What was wrong
Seven derived artifacts were committed:
packages/templates/src/generated/*(prompt templates, the plugin-SDK.d.tsembed, the--appstarter files),packages/plugin-sdk/bundled-types/*.d.ts,packages/plugin-build/src/generated/plugin-theme.generated.tsandpackages/plugin-build/src/runtime-export-manifest.ts. They are pure functions of tracked sources, but they are large files with very long lines (the dts embed is one 628 KB line), and many PRs touch them: 216, 154 and 149 commits in the last three months for the top three. Two concurrent changes to the SDK types conflicted every time. Each one also carried a--checkmode wired into typecheck/test to catch staleness.What changed
.gitignorenow coverspackages/templates/src/generated/,packages/plugin-sdk/bundled-types/andpackages/plugin-build/src/generated/; the files are removed from git (−25 K lines).runtime-export-manifest.tsmoves intosrc/generated/asruntime-export-manifest.generated.ts.turbo.jsongains generator tasks with explicitinputs/outputs:@bb/templates#generate:templates— prompts only, sub-second.@bb/templates#generate:plugin-scaffold— newscripts/generate-plugin-scaffold.mjs(split fromgenerate-templates.mjs): the--appstarter files from the committed component registry. Sub-second.@bb/plugin-build#generate— theme CSS + runtime export manifest.@get-bb/plugin-sdk#build:types— the ~20 s rollup dts bundle as its own task;#buildnow depends on it and builds only the runtime (prepackstill runs both fornpm publish)..d.tsis no longer embedded in a generated module.syncPluginTypes(bb plugin types|build|devon a vendored-layout plugin) loads the declarations at runtime viapackages/templates/src/plugin-sdk-dts.ts: the packaged CLI (host-daemon/dist/bb) inlines them through an esbuilddefineat bundle time; source and dev builds readpackages/plugin-sdk/bundled-typesfrom the workspace. So@bb/cli#build— everypnpm bb— never waits for the 20 s dts build.@bb/templates#topoand@bb/plugin-build#topodepend on their generators, so only packages that transitively depend on those two are ordered after (and hash) them. Only real consumers depend on the dts bundle:@bb/host-daemon#build(inline), the SDK's own typecheck/test,@bb/cli#test/@bb/templates#test(runtime read),@bb/integration-tests#typecheck(nosourcecondition) and the 25 in-repo plugin typechecks.--checkmode and staleness test, the--templatesflag ofscripts/build-node-entry.mjs, and the ad-hoc generator imports in theapps/{cli,server,host-daemon}build scripts. eslint/prettier ignore the generated dirs. Stale.gitignore/.gitattributesentries cleaned.prepareruns the three cheap generators onpnpm install(~0.8 s) so a fresh clone's editor resolves the imports. Editor resolution of@get-bb/plugin-sdkinsideplugins/*needs oneturbo run build:types --filter=@get-bb/plugin-sdk;AGENTS.mddocuments it.docs/cli-guide-and-skill.mdupdated.packages/plugin-registry/r/stays committed: it is served from GitHub raw at release tags fornpx shadcn add @bb/<name>.No wire change;
HOST_DAEMON_PROTOCOL_VERSIONuntouched.How you verified
distdeleted:pnpm exec turbo run build typecheck lint→ 84/84 tasks pass; repeat runs are full cache hits.bb plugin typeson a vendored-layout fixture: dev CLI reads the workspace declarations and fails with a clear message when they are absent; the packaged CLI (host-daemon/dist/bb) works with no workspace on disk (inlined).pnpm exec turbo run test --filter=@bb/templates --filter=@get-bb/plugin-sdk --filter=@bb/cli --filter=@bb/plugin-build→ all pass;apps/serverplugin-install.test.tspasses.turbo run dev --dryshows@bb/{app,server,host-daemon}#devdepend on the cheap generators only.Fixes #