Repository navigation
Description
Summary
After #7910 / #7911, a git: plugin install fetches only the resolved commit, but it still checks out — and, where the server supports partial clone, downloads — that commit's entire tree, even when the install selects a single plugin out of a monorepo (--subdirectory <path> or a .bb/plugins.json collection entry via --plugin <name>). For a marketplace monorepo that holds many plugins and other content, writing the whole working tree now dominates install time. I expected bb to materialize only the directories the selected plugin needs.
Versions and environment
- bb built from
mainataf25b0b5a604addd91e70d855c4020fd70ac56bb(includes Fetch only the resolved commit for git plugin installs #7911), macOS, git 2.56.1 - Plugin install path on the server; no provider involved
Steps to reproduce
- Register a marketplace whose source is a git monorepo with many plugins and sizeable unrelated content.
time bb plugin install <plugin>@<marketplace>for a plugin that lives in one subdirectory of that repository.- While the install job runs, watch
<dataDir>/plugins/cache/git/<host>/<org>/<repo>/<sha>.staging/fill with every directory of the commit, not just the selected plugin's.
Fixture-level repro: a repository with .bb/plugins.json listing plugins/alpha and plugins/beta plus an unrelated/ directory; after bb plugin install git:<repo>@main --plugin alpha, unrelated/ and plugins/beta are present in the shared checkout under the data dir.
Expected vs actual
I benchmarked plugin installation time with two plugins from our marketplace monorepo, on the same machine and network, with main as of #7911 ("shallow clone") versus a build with a sparse checkout of the selected directory (prototype in #7917):
| Command | Shallow clone only (#7911) | Shallow clone + sparse checkout | Speed-up |
|---|---|---|---|
time bb plugin install plugin1@my-marketplace |
1:26.62 total (0.56s user, 0.08s system) | 10.409s total (0.24s user, 0.04s system) | ~8.3× |
time bb plugin install plugin2@my-marketplace |
23.005s total (0.27s user, 0.04s system) | 7.434s total (0.23s user, 0.04s system) | ~3.1× |
Raw time output:
# plugin1, shallow clone only
0.56s user 0.08s system 0% cpu 1:26.62 total
# plugin1, sparse checkout
0.24s user 0.04s system 2% cpu 10.409 total
# plugin2, shallow clone only
0.27s user 0.04s system 1% cpu 23.005 total
# plugin2, sparse checkout
0.23s user 0.04s system 3% cpu 7.434 total
The near-zero CPU share in every row shows the CLI is waiting on the server-side install job; the difference is the server's git checkout.
Expected: the install materializes the selected plugin's directory (plus repository-root files and .bb/ for a collection entry) and nothing else, so install time is proportional to the plugin, not the monorepo.
Evidence
cloneGitCommitonmain:—bb/apps/server/src/services/plugins/managed-plugin-artifacts.ts
Lines 150 to 224 in af25b0b
async function fetchGitCommitShallow( url: string, stagingDir: string, commit: string, notFoundHint: string | undefined, ): Promise<boolean> { await runInstallCommand("git", ["init", "--quiet", stagingDir], { notFoundHint, }); try { await runInstallCommand("git", [ "-C", stagingDir, "fetch", "--quiet", "--depth", "1", "--no-tags", url, commit, ]); await runInstallCommand("git", [ "-C", stagingDir, "checkout", "--quiet", "--detach", "FETCH_HEAD", ]); return true; } catch (error) { if (error instanceof PluginInstallCancelledError) throw error; await rm(stagingDir, { recursive: true, force: true }); return false; } } async function cloneGitCommit( url: string, stagingDir: string, commit: string, notFoundHint?: string, ): Promise<void> { const shallow = await fetchGitCommitShallow( url, stagingDir, commit, notFoundHint, ); if (!shallow) { await runInstallCommand("git", ["clone", "--quiet", url, stagingDir], { notFoundHint, }); await runInstallCommand("git", [ "-C", stagingDir, "checkout", "--quiet", "--detach", commit, ]); } const checkedOutCommit = await runInstallCommand("git", [ "-C", stagingDir, "rev-parse", "HEAD", ]); if (!checkedOutCommit.startsWith(commit)) { throw new Error( `git resolved ${commit}, but checked out ${checkedOutCommit}`, ); } await rm(join(stagingDir, ".git"), { recursive: true, force: true }); } fetch --depth 1thencheckout --detach FETCH_HEADwith no--filterand nosparse-checkout, thenrm .git.- The subdirectory is only chosen after the full checkout: (
bb/apps/server/src/services/plugins/managed-plugin-artifacts.ts
Lines 852 to 856 in af25b0b
const stagedSubdirectory = await resolveSelectedSubdirectory({ checkoutDir: stagingDir, selection, sourceLabel: source, }); resolveSelectedSubdirectoryreads the staged tree, thenpluginRootDirpicks the folder). - Measured with
timearoundbb plugin installas shown above.
What you ruled out
- Not the npm install or esbuild build step: identical between the two builds, and both run after the checkout.
- Not history download: Fetch only the resolved commit for git plugin installs #7911 already limits the fetch to one commit; this is the tree write (and blob download where the server allows
--filter=blob:none). - Not a duplicate of Plugin git installs clone the whole repository instead of fetching the resolved commit #7910, which covers history depth and is fixed; searched "sparse", "subdirectory", "monorepo checkout" in open and closed issues.
Suggested priority and effort
Hits every user installing from a marketplace monorepo; no workaround short of publishing each plugin on npm. Contained change in cloneGitCommit: cone-mode git sparse-checkout of the selected directory (.bb first for a collection entry, then add the manifest's directory), --filter=blob:none from a named remote, and a fallback to the whole tree for symlinked plugin directories, which cone mode refuses. Prototype with tests: #7917.
AGENT GENERATED
Activity
bb-slop-cop commentedon Nov 24, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotplugins,perf.confirmed-repro.origin/mainataf25b0b5a6.Check out only the selected plugin's directories for git installs (ge…