Skip to content

feat(system): native Windows ls/grep/wc/tree + PowerShell cmdlet rewrites#2547

Open
tienthegainz wants to merge 2 commits into
rtk-ai:developfrom
tienthegainz:develop
Open

feat(system): native Windows ls/grep/wc/tree + PowerShell cmdlet rewrites#2547
tienthegainz wants to merge 2 commits into
rtk-ai:developfrom
tienthegainz:develop

Conversation

@tienthegainz

Copy link
Copy Markdown

Summary

• Make  rtk ls / grep / wc / tree  work on Windows. These filters previously shelled out to Unix binaries ( ls ,  rg / grep ,  wc ,  tree ) that aren't present on a stock Windows install, so they failed with "Binary not found on PATH" (or  tree.com 's "Too many parameters"). Each now has a native Rust execution path used when the Unix binary is absent (detected via  tool_exists ;  tree  always goes native on Windows). All native paths reuse the existing compression filters, so token-savings behavior is unchanged.
• Auto-rewrite common PowerShell cmdlets to their rtk equivalents so the hook saves tokens for Windows/PowerShell agents:  Get-Content / gc / type  →  rtk read ,  Get-ChildItem / gci / dir  →  rtk ls  ( -Recurse  →  rtk tree ,  -Force  →  -a ),  Select-String / sls  →  rtk grep  ( -i  unless  -CaseSensitive ). Only single, non-piped invocations are rewritten so PowerShell pipelines are never broken; unmappable params (e.g.  -Filter ) and unknown cmdlets pass through untouched.
• Adds a backslash-safe PowerShell tokenizer ( ps_split ) so Windows paths like  src\cmds  survive rewriting, plus docs in  src/cmds/system/README.md .

Test plan

✓  cargo fmt --all && cargo clippy --all-targets && cargo test 
• fmt clean; clippy zero warnings; 2235 tests pass. (The 16 failing  core::stream::tests::*  are pre-existing Windows-environment failures — they spawn Unix  sh / cat / echo / sleep  — and are unrelated to this change; verified  core/stream.rs  is untouched.)
• 30 new tests added: native  wc  counts/columns,  ls  synthetic-line round-trip,  tree  arg parsing, native  grep  matching ( -i / -v , NUL-format parse round-trip), and 16 PowerShell-rewrite cases incl. backslash-path and piped-passthrough regressions.
✓ Manual testing:  rtk   output inspected on Windows (rtk 0.42.4):
•  rtk ls src\cmds\system  → compact  name size  listing + summary (was: "Binary 'ls' not found")
•  rtk grep "fn run" src\cmds\system  →  34 matches in 14 files:  grouped output, no rg/grep warnings (was: "Binary 'rg'/'grep' not found")
•  rtk wc Cargo.toml  →  72L 246W 1796B  (was: "Binary 'wc' not found")
•  rtk tree -L 1 src  → compact pruned tree (was: "Too many parameters")
•  rtk hook check --agent copilot "Get-ChildItem -Recurse src\cmds"  →  rtk tree src\cmds 
•  rtk gain --history  confirms commands tracked (~80% savings)

Important: All PRs must target the develop branch (not master).
See CONTRIBUTING.md for details.

@CLAassistant

CLAassistant commented Jun 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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