Commit Graph
2 Commits
Author SHA1 Message Date
Abhay Singh 3a3a465bb1 feat(wrap): extend reduce-at-source quiet defaults to telemetry/nag banners (#2550)
## Description

Extends the reduce-at-source quiet-CLI env defaults added in #2548. That
set covered git/pip/npm chatter (pager framing, progress bars,
funding/audit banners, version nags). But coding agents constantly shell
out to other common tools that print **zero-signal** telemetry pings,
version nags, and first-run / logo banners into `tool_result` output —
tokens the agent never acts on and the proxy then has to carry.

This adds SAFE defaults for those, following the exact criterion in
#2548's comment: only knobs that suppress chatter, never anything that
could hide diffs, errors, summaries, or search results.

New entries:

- `npm_config_update_notifier=false` — npm's boxed "update available"
notice
- `DO_NOT_TRACK=1` — the cross-tool telemetry opt-out standard
(consoledonottrack.com), honored by turbo, netlify, gatsby, and many
others
- `DOTNET_CLI_TELEMETRY_OPTOUT=1`, `DOTNET_NOLOGO=1` — .NET SDK
telemetry ping + the "Welcome to .NET" logo/copyright banner
- `NEXT_TELEMETRY_DISABLED=1`, `GATSBY_TELEMETRY_DISABLED=1`,
`ASTRO_TELEMETRY_DISABLED=1` — JS framework build/dev telemetry banners
- `NG_CLI_ANALYTICS=false` — Angular CLI analytics ping + first-run
prompt
- `HOMEBREW_NO_ENV_HINTS=1` — Homebrew's `==> ... hints` chatter (not
warnings/errors)

Each is the canonical, widely-documented "disable telemetry / nag"
variable for its tool. As with the existing set, a value the user
already set always wins (defaults fill only when absent), and the whole
feature is opt-out via `HEADROOM_WRAP_QUIET=0`.

## Type of Change

- [ ] Bug fix (non-breaking change that fixes an issue)
- [x] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring (no functional changes)

## Changes Made

- `headroom/cli/wrap.py`: add the telemetry/nag/banner env defaults to
`_QUIET_CLI_DEFAULTS`.
- `tests/test_wrap_quiet_cli.py`: assert the new suppressors are
injected into an empty env (and, via the existing tests, still respect
user overrides and the opt-out switch).

## Testing

- [x] Unit tests pass (`pytest`)
- [x] Linting passes (`ruff check .`)
- [x] Type checking passes (`mypy headroom`)
- [x] New tests added for new functionality
- [ ] Manual testing performed

### Test Output

```text
$ python -m pytest tests/test_wrap_quiet_cli.py -q
6 passed

# with the new defaults reverted, the telemetry-suppressor test fails
# (the keys are absent from the injected env)

$ uvx ruff@0.15.17 check headroom/cli/wrap.py tests/test_wrap_quiet_cli.py
All checks passed!
```

## Real Behavior Proof

- Environment: Windows 11, Python 3.12, project venv (`uv sync --extra
proxy`), `uvx ruff@0.15.17`, pytest in the venv.
- Exact command / steps: called `_configure_quiet_cli_env({})` with
`HEADROOM_WRAP_QUIET` unset and inspected the resulting env; also
exercised the existing user-override and opt-out tests; then reverted
the source and re-ran.
- Observed result: with the change the new keys (`DO_NOT_TRACK`,
`DOTNET_CLI_TELEMETRY_OPTOUT`, `DOTNET_NOLOGO`,
`NEXT_/GATSBY_/ASTRO_TELEMETRY_DISABLED`, `NG_CLI_ANALYTICS`,
`HOMEBREW_NO_ENV_HINTS`, `npm_config_update_notifier`) are present with
their documented values and reported in the written list; a user-set
value is left untouched; and with `HEADROOM_WRAP_QUIET=0` nothing is
injected. With the change reverted the new keys are absent. Ran against
the actual module.
- Not tested: launching each real CLI to observe the reduced output (the
env variables are each tool's own documented telemetry/nag switch).

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] I have updated the CHANGELOG.md if applicable

cc @chopratejas
2026-10-03 00:12:44 -05:00
Tejas Chopra c990cfb803 feat(wrap): reduce-at-source — SAFE quiet-CLI env defaults for the launched agent (#2548)
## Description
Reduce-at-source, done **safely** in the wrap layer (not by rewriting
commands in-flight): `headroom wrap` injects conservative quiet-CLI env
defaults into the launched agent's environment so tools emit less noise
at the source (which the proxy would otherwise strip post-hoc).

Injected only when the user hasn't set them: `GIT_PAGER=cat`,
`PIP_QUIET=1`, `PIP_DISABLE_PIP_VERSION_CHECK=1`,
`npm_config_fund/audit/progress=false`; `PYTEST_ADDOPTS` **augmented**
with `-q` (existing value preserved). Single chokepoint
(`_launch_tool`), so it covers all wrapped tools. Opt out with
`HEADROOM_WRAP_QUIET=0`.

Closes #

## Type of Change
- [x] Performance improvement / [x] New feature (opt-out)

## Safety
Nothing that can suppress diffs, errors, summaries, or search results —
no blanket `--silent`/`--quiet`. User-set values always win.

## Testing
```text
pytest tests/test_wrap_quiet_cli.py → 5 passed (defaults injected; user value wins; PYTEST_ADDOPTS augmented; opt-out; on-by-default)
ruff + mypy → clean
```

## Scope note (honesty)
A JSONL analysis of real Claude Code traffic shows this is a **modest**
lever for that workload: non-TTY git already disables the pager (so
`GIT_PAGER` is largely a no-op there), and pip/npm are low-traffic;
`PYTEST_ADDOPTS=-q` is the clearest win. It's harmless and captures
modest savings where those tools *are* used — the larger levers are
post-output (the lossless-guard lossy tier) and the grep fold.

## Checklist
- [x] Self-reviewed; tests pass; no CHANGELOG edit
2026-07-24 20:40:52 -07:00