Skip to content

fix(widgets/mcp-install): make uvx + pipx + pip cooldown snippets resolvable for fresh releases#58

Open
tony wants to merge 2 commits into
mainfrom
fix/cooldown-exempt-self-package
Open

fix(widgets/mcp-install): make uvx + pipx + pip cooldown snippets resolvable for fresh releases#58
tony wants to merge 2 commits into
mainfrom
fix/cooldown-exempt-self-package

Conversation

@tony
Copy link
Copy Markdown
Member

@tony tony commented May 19, 2026

Summary

  • Add --exclude-newer-package libtmux-mcp=2099-01-01 to every uvx + days panel (CLI, JSON, TOML body shapes) so a security-conscious cooldown stays applied to transitive deps without filtering libtmux-mcp itself out of the resolver.
  • Fall (pipx, *) and (pip, *) panels back to the bare install command and surface the limitation in a redirect note. Removes broken pipx run --pip-args=--uploaded-prior-to=<DATE> libtmux-mcp and pip install … --uploaded-prior-to … libtmux-mcp snippets that emit ERROR: Could not find a version that satisfies the requirement libtmux-mcp whenever the cutoff filters fresh releases.

Why

The previous snippets were copy-paste foot-guns: any time a libtmux-mcp release was newer than the cooldown window, the snippet's cutoff would filter the target package itself out of the resolver. Direct source verification:

  • pip 26.1.1 (_internal/cli/cmdoptions.py:463): --uploaded-prior-to parses both P7D and absolute dates, but it's a single global cutoff — no per-package override flag exists. pip issue #13674 added the duration parser; no per-package issue is open.
  • pipx 1.8.0 bundles pip 26.0.1 (which rejects P7D with "Invalid isoformat") and commands/run_uv.py::_UV_TRANSLATABLE_VALUE_FLAGS whitelists only --index-url, --pre, --no-deps, --no-cache-dir, --upgrade — neither --exclude-newer nor --uploaded-prior-to is forwarded to the uv backend.
  • uv (crates/uv-distribution-types/src/exclude_newer.rs:209): supports P7D natively and has --exclude-newer-package <pkg>=<date> for per-package overrides. uv issues #18386 and #17999 cover related per-package work.

So uv is the only path where a per-package cooldown override exists today. The widget now reflects that.

What changed

docs/_ext/widgets/mcp_install.py

  • _tool_command(): uvx + days emits uvx --exclude-newer <DURATION> --exclude-newer-package libtmux-mcp=2099-01-01 libtmux-mcp. pipx + days / off / bypass all emit bare pipx run libtmux-mcp. pip is unchanged at this layer (return "libtmux-mcp").
  • _pip_prereq_for(): always returns pip install --user --upgrade libtmux libtmux-mcp regardless of cooldown mode (was emitting --uploaded-prior-to for days, which was broken).
  • _json_body() and _toml_body(): uvx + days carries the same exempt flag; pipx + days / off / bypass all emit the same bare args / args_inner.
  • _cooldown_note(): single redirect note for any (pipx | pip, days | bypass) cell — "pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via `--exclude-newer` while exempting libtmux-mcp itself via `--exclude-newer-package`."
  • Drop unused _DATE_SENTINEL and PIP_PREREQ_DAYS constants.

tests/docs/test_widgets.py

  • test_body_for_uvx_days_inserts_duration_sentinel now also asserts the --exclude-newer-package libtmux-mcp=2099-01-01 exempt appears.
  • New test_body_for_pipx_days_falls_back_to_bare_run asserts pipx + days emits the same bare command as off, with no --pip-args / --uploaded-prior-to / <COOLDOWN_DATE>, and the note redirects to uvx.
  • New test_body_for_pip_days_falls_back_to_bare_install mirrors the pipx test for pip.
  • test_body_for_pipx_bypass_returns_caveat_note and test_body_for_pip_bypass_returns_caveat_note updated to assert the new redirect-to-uvx prose.
  • test_pip_panel_has_cooldown_aware_pip_prereq renamed to test_pip_panel_has_bare_pip_prereq_across_modes; asserts all three pip cooldown modes emit the same bare prereq.
  • test_cooldown_days_slot_filter_registered_on_widget_render updated to drop the date-slot assertion — no widget emits <COOLDOWN_DATE> anymore.

CHANGES

  • New ### Fixes entry under the unreleased block describing the mcp-install widget fix and citing the pip / pipx / uv source evidence.

Test plan

  • uv run ruff check . --fix --show-fixes clean
  • uv run ruff format . clean
  • uv run mypy clean (51 source files, no issues)
  • uv run py.test --reruns 0 — 483 passed
  • just build-docs succeeds
  • Live verified: pipx run libtmux-mcp starts the MCP server (exit 0) — confirms the new bare snippet works where the old --pip-args=--uploaded-prior-to=... form failed
  • Live verified: the cli-install fix shape in agentgrep on tony/agentgrep#feat/cli-section using the same per-package exempt pattern resolves and runs

Companion change

The same fix shipped to agentgrep's mcp-install + cli-install widgets on tony/agentgrep's feat/cli-section branch. Both repos share the same git-pull workspace widget design; both needed the same fix.

…ude-newer in days panels

why: The mcp-install widget's uvx-flavored days-mode snippets emitted ``uvx --exclude-newer P7D libtmux-mcp`` without a per-package override, so a fresh release of libtmux-mcp (newer than the cooldown cutoff) made the install unresolvable — ``no versions of libtmux-mcp`` from uv's resolver. uv's hint points at ``--exclude-newer-package <pkg>=<date>`` as the per-package override; setting it to a far-future date exempts the target package while keeping the cooldown applied to transitive deps. Identical pattern to the fix on the sibling agentgrep project.

what:
- Insert ``--exclude-newer-package libtmux-mcp=2099-01-01`` after ``--exclude-newer <DURATION>`` in the uvx + days branches of _tool_command, _json_body, and _toml_body, so every uvx + days panel (CLI, JSON, TOML body shapes) carries the exemption.
- Extend _cooldown_note to surface a caveat for (pipx, days) and (pip, days) panels — pip's ``--uploaded-prior-to`` is a global cutoff with no per-package override, so when the cooldown filters out a recent libtmux-mcp release the snippet stays unresolvable. The caveat points readers at the uvx snippet, which carries the exemption.
- Update test_body_for_uvx_days_inserts_duration_sentinel to assert the new flag appears in the rendered command. The other uvx-days tests use substring assertions on ``"--exclude-newer"`` / ``"<COOLDOWN_DURATION>"`` so they pass unchanged.
- No changes to bypass / off panels — bypass already skips any global uv cooldown via ``--no-config``, off has no cutoff, both stay resolvable.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.94%. Comparing base (3cb9aa4) to head (85ad5b8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #58      +/-   ##
==========================================
- Coverage   86.02%   85.94%   -0.09%     
==========================================
  Files          40       40              
  Lines        2454     2440      -14     
  Branches      325      319       -6     
==========================================
- Hits         2111     2097      -14     
  Misses        260      260              
  Partials       83       83              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…ck to bare commands

why: ``pipx run --pip-args=--uploaded-prior-to=<DATE> libtmux-mcp`` fails with ``ERROR: Could not find a version that satisfies the requirement libtmux-mcp`` whenever the cutoff filters fresh libtmux-mcp releases. Verified directly against pip 26.1.1's source (``_internal/cli/cmdoptions.py:463``): ``--uploaded-prior-to`` is a single global cutoff with no per-package override flag. pipx's ``commands/run_uv.py::_UV_TRANSLATABLE_VALUE_FLAGS`` only forwards a narrow whitelist of pip args to its uv backend (no ``--exclude-newer`` / ``--uploaded-prior-to``), so the uv backend can't carry the cooldown either. Mirrors the same fix landed in agentgrep this round.

what:
- ``_tool_command`` / ``_pip_prereq_for`` / ``_json_body`` / ``_toml_body`` all return the bare command for (pipx, *) and (pip, *) — no ``--pip-args=--uploaded-prior-to`` or ``--uploaded-prior-to`` flag emitted. The uvx days panels keep ``--exclude-newer P7D --exclude-newer-package libtmux-mcp=2099-01-01`` since uv has both flags.
- ``_cooldown_note`` for (pipx | pip, days | bypass) now returns a single redirect note: "pip has no per-package cooldown override, so this snippet runs without cooldown enforcement. Switch to the uvx tab — it applies the cooldown to transitive deps via ``--exclude-newer`` while exempting libtmux-mcp itself via ``--exclude-newer-package``." Drops the old separate (pipx, bypass) and (pip, bypass) notes.
- Remove the now-unused ``_DATE_SENTINEL`` constant and ``PIP_PREREQ_DAYS`` constant from mcp_install.py.
- Update test_body_for_pipx_days_uses_pip_args_form_with_absolute_date → test_body_for_pipx_days_falls_back_to_bare_run; add test_body_for_pip_days_falls_back_to_bare_install; replace test_pip_panel_has_cooldown_aware_pip_prereq with test_pip_panel_has_bare_pip_prereq_across_modes; update test_cooldown_days_slot_filter_registered_on_widget_render to drop the date-slot assertion (no widget emits it anymore).
@tony tony force-pushed the fix/cooldown-exempt-self-package branch from bad15d0 to 85ad5b8 Compare May 19, 2026 02:03
tony added a commit to tony/agentgrep that referenced this pull request May 19, 2026
agentgrep ships a CLI documentation surface to match the existing
MCP and library surfaces. The docs site gains a /cli/ section with
per-subcommand reference pages auto-generated from the argparse
tree, the homepage and sidebar lead with the terminal as a
first-class entry point, and a new {cli-install} install picker
mirrors {mcp-install}'s "Configure cooldowns" UX so terminal users
get the same supply-chain controls as MCP users.

**CLI reference site** — new `/cli/` toctree above Library, with
`agentgrep search` and `agentgrep find` pages auto-generating
their option lists from the live argparse tree via gp-sphinx's
`sphinx-autodoc-argparse` extension. Every subcommand page
documents `--json` / `--ndjson` output for shell pipelines and
agents that don't speak MCP.

**`{cli-install}` widget** — install-method picker (uvx, pipx,
uv add, pip) carrying the same "Configure cooldowns" picker the
MCP installer has had since 0.1.0a3: off / days / bypass
variants, settings sub-view with bypass radio and days input,
live update of the duration / date sentinels on every keystroke,
state shared across pages and across both install widgets via a
broadcast event.

**Library install widget refresh** — replaces the `uvx run` /
`pipx run` panels (tool-runners, wrong shape for library
consumption) with a PEP 723 inline-metadata script, `uv add`,
and `pip install`. Storage key bumps so any stale saved selection
falls back to the new default.

**Sidebar flatten** — each section caption (CLI / Library / MCP /
Reference) now reads as a single flat tier with the landing shown
as "Overview" alongside its sub-pages, replacing the previous
nested-dropdown shape.

**README + sidebar order** — README leads with the CLI
quickstart, then MCP, then Library, matching the new sidebar
caption order.

### Fixes

**MCP install widget cooldown snippets** — 0.1.0a3's mcp-install
widget emitted
`uvx --exclude-newer <DURATION> --from agentgrep agentgrep-mcp`
without a per-package override, so any cooldown window shorter
than agentgrep's most-recent-release age made the install
unresolvable (uv emits `no versions of agentgrep`). uvx and
`uv add` days panels now carry `--exclude-newer-package
agentgrep=2099-01-01` so the cooldown hits transitive deps
without filtering agentgrep itself out of the resolver. pipx and
pip days/bypass panels fall back to the bare install command and
redirect readers to the uvx tab — pip's `--uploaded-prior-to`
has no per-package override flag, and pipx's uv-backend pip-args
whitelist doesn't forward `--exclude-newer` either.

### Companion change

The same mcp-install cooldown fix shipped to libtmux-mcp's
install widget at tmux-python/libtmux-mcp#58 — both projects
share the same git-pull workspace install-widget design.
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.

2 participants