feat(ssh): add ssh command with output truncation#1043
Open
lgbarn wants to merge 2 commits intortk-ai:developfrom
Open
feat(ssh): add ssh command with output truncation#1043lgbarn wants to merge 2 commits intortk-ai:developfrom
lgbarn wants to merge 2 commits intortk-ai:developfrom
Conversation
This was referenced Apr 12, 2026
Add first-class `rtk ssh` command that passes through to ssh but compacts the output: blank lines are stripped and results are capped at 80 lines. Stderr (connection warnings, errors) is capped at 5 lines. SSH remote commands frequently produce verbose output (docker logs, journal dumps, systemctl status) that wastes tokens. `rtk discover` showed 326 unhandled ssh commands over 30 days. Closes rtk-ai#783 Closes rtk-ai#333
Add missing tests per project testing rules: - Token savings verification (≥50% on verbose output) - Truncated output format validation (line boundaries) - Stderr isolation (not leaked into filtered output)
3ed0bfa to
1bbc86c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rtk sshcommand that passes through to ssh and compacts outputssh host cmd→rtk ssh host cmdvia hookCloses #783
Closes #333
Motivation
rtk discovershowed 326 unhandledsshcommands over 30 days. SSH remote commands frequently produce verbose output (docker logs, journal dumps, systemctl status) that wastes tokens when piped back to an LLM.Changes
src/cmds/cloud/ssh_cmd.rssrc/discover/rules.rssshrule (pattern^ssh\s+\S+, category Infra, 50% est. savings)src/main.rsSshcommand variant, dispatch, and hook registrationDesign decisions
Test plan
cargo test ssh— 4 new tests pass (truncation, short output, blank lines, empty)cargo test— 1257 passed, 3 ignored, 0 failedrtk rewrite "ssh pi@rpi docker ps"→rtk ssh pi@rpi docker ps