Skip to content

feat(pkg): compress yarn and bun install logs - #11

Open
osazemeu wants to merge 1 commit into
jee599:mainfrom
osazemeu:feat/pkg-yarn-bun-install-log-compression
Open

osazemeu wants to merge 1 commit into
jee599:mainfrom
osazemeu:feat/pkg-yarn-bun-install-log-compression

Conversation

@osazemeu

@osazemeu osazemeu commented Sep 5, 2026

Copy link
Copy Markdown

Summary

  • Extends compress_pkg_log to handle yarn and bun install output, alongside the existing npm and pip support (Add yarn/bun package install log compression #3).
  • yarn is covered in both dialects: classic v1 line prefixes, and the YNnnnn codes berry emits from v2 onwards.
  • bun loses its banner, dotenv notice and non-TTY progress lines; its summary is hoisted the way npm's already is, and the per-package + pkg@version rows collapse to a count above five.

How noise is told apart from signal

The interesting part of yarn is that the split is structural rather than semantic. warning <path>@<version>: <message> with an unquoted dependency path is the registry's deprecated field echoed back, which is exactly what npm's npm warn deprecated already is, so it is dropped under the same rule. warning "<path>" has (unmet|incorrect) peer dependency "<spec>". always opens with a quote and is kept. Matching on the quote is sturdier than matching on the message text, which varies per package.

Berry is a denylist over message codes with default-keep, never an allowlist. Two cases forced that:

  • YN0000 lines carrying a prefix are where berry reports build script stdout and stderr. Dropping YN0000 by code would have silently eaten the stderr of a failed postinstall and left the model a truncated log under a cheerful summary. There is a test for this.
  • A resolution failure ends with ➤ Errors happened when preparing the environment required to run this command., which carries no code at all. An allowlist would have dropped it.

One rule is placed ahead of the security check: Node's own (node:NNNN) [DEP0169] DeprecationWarning notice, which appears in every yarn v1 run on current Node and mentions "security implications". It is tightly anchored and commented in place. Nothing else precedes that check.

Step lines are matched as ^\[\d+/\d+\] rather than /4, since yarn remove prints /2 and yarn install --audit prints /5. bun patterns tolerate the one-space indent that 1.0.x used.

Test plan

  • cargo fmt --all --check && cargo clippy --all-targets && cargo test (1132 + 7 tests pass; the one clippy warning is pre-existing in wget_cmd.rs and untouched here)
  • Manual testing: fixtures are real captures, not synthetic. Generated locally from yarn 1.22.22, yarn 4.18.0 and bun 1.4.2 with both streams piped, including failing installs.

Token savings against those fixtures:

fixture saved
yarn install (classic 1.22.22) 65.1%
yarn install (berry 4.18.0) 73.0%
bun install (1.4.2) 80.5%

The berry figure is the pessimistic case. Yarn 2 and 3 re-emit YN0013 cache lines in a sliding window, roughly 250 lines for 54 unique packages, where yarn 4 collapses that to a single aggregate line. The same rule is worth considerably more on 2 and 3.

Failure paths are asserted to survive rather than to compress. test_yarn_berry_keeps_build_script_output, test_yarn_berry_failure_survives_intact, test_yarn_v1_keeps_errors_and_stack and test_bun_keeps_errors_and_warnings all check that error text, stack frames and Blocked N postinstalls come through intact.

Docs

Updated the Package install noise row in README.md and the 12 translated READMEs. CHANGELOG.md is left alone since release-please generates it.

Notes for the reviewer

Two small deviations from CONTRIBUTING.md, both because the documented instruction does not apply here:

  • The branch naming example feat(scope): description is not a legal git ref, since colons are disallowed. Used feat/pkg-yarn-bun-install-log-compression.
  • CONTRIBUTING says to target develop; this repository only has main.

Scope is filter only, per the issue. There is no contextzip yarn / contextzip bun command today, so this is reachable through the shared compress_pkg_log path rather than a route of its own. Background on the scope call and on what the real output looks like is in #3.

Two pre-existing problems turned up while working on this. Neither is caused or fixed by this PR, both filed separately: #12 (unanchored drop rules plus no error guard can lose lines from failing build scripts) and #13 (OSC-8 hyperlinks survive the CSI-only ANSI strippers).

Extends compress_pkg_log to cover yarn and bun alongside npm and pip.

yarn is handled in both dialects. Classic v1 is matched on its line
prefixes: the banner, [n/m] step lines, dead info lines, and the echo of
a package's deprecated field, which is the direct analogue of npm's
"npm warn deprecated". Peer dependency warnings survive, because they
open with a quote where those advisories do not, which is a sturdier
test than matching on the message text. Berry is matched on the YNnnnn
codes it emits from v2 onwards, dropping structural framing, version
notices and the per-package cache chatter that makes up most of a yarn 2
or 3 log. YN0000 lines carrying a box-drawing prefix are deliberately
left alone, since that is where berry reports build script stdout and
stderr.

bun loses its banner, its dotenv notice and the static progress lines it
prints in place of a spinner when stderr is not a terminal. The install
summary is hoisted the way npm's already is. The per-package "+ pkg@ver"
rows collapse to a count above five, where bun is listing the project
rather than reporting a change and package.json already has the list,
and stay verbatim below it where they are a useful diff.

Node's own DEP0169 notice shows up in every yarn v1 run on current Node
and mentions "security implications", so it is matched ahead of the
security check. It is the only rule placed before it.

Fixtures are real captures from yarn 1.22.22, yarn 4.18.0 and bun 1.4.2
with both streams piped. Savings on those are 65% for yarn v1, 73% for
berry and 81% for bun. Failure paths are asserted to survive intact,
including the berry build failure case, which is the one place a filter
like this can lose something that matters.

Closes jee599#3

Signed-off-by: Osazeme Usen <osazemeu@yahoo.com>
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