Skip to content

fix(coding-agent): reduce Git package installation storage - #7

Open
JohnsonRan wants to merge 2 commits into
xz-dev:patch/use-embedded-bun-package-managerfrom
JohnsonRan:fix/git-package-storage
Open

fix(coding-agent): reduce Git package installation storage#7
JohnsonRan wants to merge 2 commits into
xz-dev:patch/use-embedded-bun-package-managerfrom
JohnsonRan:fix/git-package-storage

Conversation

@JohnsonRan

@JohnsonRan JohnsonRan commented Sep 13, 2026

Copy link
Copy Markdown

Summary

Reduce the entire .pi/agent/git installation footprint, including node_modules, through two changes:

1. Avoid installing Pi itself again inside each extension

install --omit=dev still allows automatic peer installation. Extensions declaring Pi as a peer can therefore pull Pi itself and its transitive SDK dependencies into their own node_modules. Embedded Bun also does this when Pi is declared as both a dev and peer dependency.

Default Git dependency installs now use:

  • Embedded Bun: install --omit=dev --omit=peer.
  • npm: install --omit=dev --legacy-peer-deps.

This matches the existing managed npm-package peer policy. Controlled fixtures verified that omitting peers prevents the redundant host installation while retaining ordinary runtime dependencies. Explicit npmCommand overrides are unchanged. Packages declaring Pi in ordinary dependencies still install it.

2. Avoid downloading unnecessary Git history

  • Clone only the selected branch/tag at depth one, without unrelated tags. Fetch full commit IDs directly; abbreviated commit IDs retain full cloning for local resolution.
  • Keep updates shallow and discard invalidated commit-graph caches without deleting existing refs, reflogs or stored objects.

Targets the persistent patch/use-embedded-bun-package-manager branch so the changes survive main's sync rebuild. No sync workflow change is needed.

Measurement: Git history only, excluding node_modules

18 installed repositories were shallow-cloned into temporary directories at the same HEAD. All clones passed git fsck; original installation file hashes were unchanged. Six repositories were already shallow.

Logical size Before Shallow-clone equivalent
Git metadata 27.10 MiB 8.14 MiB
Entire installation excluding node_modules 49.07 MiB 30.11 MiB

The shallow-clone change alone saves 18.96 MiB (38.6%) in this measurement. These figures exclude node_modules; they do not quantify the additional benefit of avoiding redundant Pi/SDK dependencies.

This is a fresh-clone-equivalent measurement, not an in-place cleanup or a claim about physical disk reclamation. node_modules can share hardlinks with caches and other installations, so its logical size is not the amount of disk space recoverable by deleting it.

Existing extra dependencies and old Git objects are not automatically pruned. These changes reduce fresh installation size; rerunning installation does not guarantee removal of existing redundant dependencies.

Validation

  • npm run check: passed on the persistent-branch candidate and main integration.
  • Native WSL Linux: npm run build:offline, ./test.sh, and 230 focused tests passed.
  • Real local Git tests cover branch/tag/commit selection, omitted-history updates, failure cleanup, and full clones with single-file/split commit graphs.
  • Separate test-only commit isolates mocked Linux clipboard cases from the real WSL /proc/version. Assertions and production clipboard behavior are unchanged.

One earlier full-suite run reported an empty-answer failure in the experimental remote runtime. Three candidate and three baseline isolated runs did not reproduce it; the final full suite passed. No fix is claimed for that intermittent failure.

This PR was prepared with AI assistance.

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