rtk-ai/rtk

Normalize .venv/bin/ and virtualenv prefixes before registry lookup

Open

#1,206 创建于 2026年4月10日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)Rust (2,914 fork)batch import
area:clibugeffort-mediumenhancementhelp wantedpriority:medium

仓库指标

Star
 (48,085 star)
PR 合并指标
 (平均合并 11天 1小时) (30 天内合并 45 个 PR)

描述

Problem

RTK does not match virtualenv-prefixed tool invocations against its registry, even when a filter exists for the tool.

Repros (rtk 0.35.0):

$ rtk rewrite ".venv/bin/pytest --tb=short"
# exit 1 — no rewrite, even though rtk pytest exists

$ rtk rewrite ".venv/bin/ruff check ."
# exit 1 — no rewrite, even though rtk ruff exists

Note: rtk discover -a classifies these as "MISSED SAVINGS" with status existing (implying RTK can handle them), but rtk rewrite fails. The discover classification is based on tool-name recognition, not actual rewrite-engine matching — this discrepancy is misleading.

Paths to normalize:

  • .venv/bin/<tool> — relative virtualenv (most common)
  • ./.venv/bin/<tool> — explicit relative
  • /home/user/project/.venv/bin/<tool> — absolute path to venv bin directory
  • venv/bin/<tool>, virtualenv/bin/<tool> — alternate venv directory names
  • On Windows: .venv/Scripts/<tool>.exe

Expected behavior

.venv/bin/pytest --tb=short → strip prefix, look up pytest in registry → rtk pytest --tb=short

If the tool has no RTK filter after normalization, fall through to passthrough as today.

Impact

In this project: 550 .venv/bin/pytest and 376 .venv/bin/ruff invocations per rtk discover -a — ~926 total currently passing through unfiltered (~178K estimated saveable tokens).

贡献者指南