You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rewrite: declines env-wrapped (env -u) and sudo-prefixed commands #4099
rtk rewrite correctly handles most wrapper prefixes (assignment prefixes, nohup, time, compound && chains), but declines to rewrite (returns empty output) for two common forms:
env -u VAR <heavy-cmd> — environment-scrubbed invocations
sudo <heavy-cmd>
Repro (rtk 0.49.0)
$ rtk rewrite 'env -u GH_TOKEN gh pr list'
(empty output — declined)
$ rtk rewrite 'env GH_TOKEN=x gh pr list'
env GH_TOKEN=x rtk gh pr list # works
$ rtk rewrite 'sudo git status'
(empty output — declined)
$ rtk rewrite 'nohup cargo test &'
nohup rtk cargo test & # works
$ rtk rewrite 'time git status'
time rtk git status # works
Impact
In a 14-day audit of one opencode install (49.5k bash calls), env -u <cmd> appeared 587 times — each declined call runs completely uncompressed (~1KB+ raw output per call, multiplied by LLM context replay).
Expected
Rewrite through the wrapper: env -u GH_TOKEN rtk gh pr list and sudo rtk git status (assuming rtk is on the secured PATH for sudo, or documenting why it is skipped).
rtk rewrite fails to descend through env -u and sudo wrapper prefixes, leaving high-frequency wrapped invocations (587 occurrences of env -u in a 14-day audit) uncompressed; extend the wrapper-prefix parser to handle these two forms like it already does for nohup/time/env VAR=x.
This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.
📁 Relevant files
src/rewrite.rs
Triaged automatically by wshm · This is an automated analysis, not a human review.
I’ll add red-first coverage for env -u VAR <supported-command> and make classification and rewriting use the same wrapper boundary so the prefix is preserved. I’ll also pin the existing sudo behavior rather than changing it: #2810 deliberately stopped emitting sudo rtk … because that can fail under secure_path or run RTK’s own side effects as root, while #146 tracks the safe rtk sudo … design. I’ll reference this PR as a partial fix instead of claiming the separate sudo feature is complete.
AI disclosure: I’m using OpenAI Codex (gpt-5.6-sol) to assist with source inspection, implementation, and verification. I’ll review the exact diff, use my DCO-signed GitHub noreply identity, and report the checks actually run.
Activity
rtk-wshm-sync-bot commentedon Sep 17, 2026
🔍 Automated Triage
bugmediumSummary
rtk rewrite fails to descend through env -u and sudo wrapper prefixes, leaving high-frequency wrapped invocations (587 occurrences of env -u in a 14-day audit) uncompressed; extend the wrapper-prefix parser to handle these two forms like it already does for nohup/time/env VAR=x.
📁 Relevant files
src/rewrite.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
taljeon commentedon Sep 18, 2026
I can take the
env -uportion of this.I’ll add red-first coverage for
env -u VAR <supported-command>and make classification and rewriting use the same wrapper boundary so the prefix is preserved. I’ll also pin the existingsudobehavior rather than changing it: #2810 deliberately stopped emittingsudo rtk …because that can fail undersecure_pathor run RTK’s own side effects as root, while #146 tracks the safertk sudo …design. I’ll reference this PR as a partial fix instead of claiming the separate sudo feature is complete.AI disclosure: I’m using OpenAI Codex (
gpt-5.6-sol) to assist with source inspection, implementation, and verification. I’ll review the exact diff, use my DCO-signed GitHub noreply identity, and report the checks actually run.