Open
Conversation
Collaborator
|
Thanks for adding AWS CLI and psql support — great additions to RTK's ecosystem! Tests pass (428/428), build is clean, and existing commands are unaffected. Here are some items to address Critical
Improvements
Minor
Overall solid work, looking forward to the next iteration! 🔧 |
Add two new command modules that compress verbose AWS CLI and PostgreSQL
client output for significant token savings when used with LLMs.
## aws_cmd (AWS CLI)
- Specialized filters for 8 high-frequency commands:
- `sts get-caller-identity` → single-line `AWS: <account> <arn>`
- `s3 ls` → compact listing, 30-item overflow counter
- `ec2 describe-instances` → one line per instance with name tag
- `ecs list-services` → short names extracted from ARNs
- `ecs describe-services` → `name status running/desired (launch)`
- `rds describe-db-instances` → `name engine version class status`
- `cloudformation list-stacks` → `name STATUS date`
- `cloudformation describe-stacks` → same + outputs section
- Generic fallback: compress JSON at depth 4 via json_cmd schema
- Only injects `--output json` for structured ops (describe-/list-/get-),
not for mutating/transfer ops (s3 cp, s3 sync, cloudformation deploy…)
- All filters use serde_json::Value for resilience (no typed structs)
- Max 20 items shown per command, overflow counter for rest
## psql_cmd (PostgreSQL)
- Detects table format (`----+----` separators) and expanded format
(`-[ RECORD N ]-` markers); passthrough for COPY, notices, etc.
- Table filter: strips borders, `(N rows)` footer, converts to tab-separated
(30-row limit with overflow counter)
- Expanded filter: converts verbose field-per-line format to compact
`[N] key=val key=val` one-liners (20-record limit)
- Tracking recorded only on success (exit code 0)
- Module-level lazy_static! regex patterns (compile once, reuse)
## Hook integration
- Both hook files updated to rewrite `aws ...` → `rtk aws ...`
and `psql ...` → `rtk psql ...`
## Tests
- 17 unit tests for aws_cmd, 17 for psql_cmd (429 total, all passing)
- Token savings tests use include_str! with real-format fixtures:
tests/fixtures/aws_ec2_describe.json — 2-instance multi-field response
tests/fixtures/aws_sts_identity.json — STS response
tests/fixtures/psql_table.txt — 20-row 7-column padded table
tests/fixtures/psql_expanded.txt — 5-record expanded display
- EC2 and STS filters verified ≥60% savings; expanded psql ≥60%;
table psql ~40% (mathematical limit of tab-conversion: |→tab saves
at most ~47% regardless of column count, documented in test)
940d2df to
e50ef8b
Compare
- Extract join_with_overflow() to utils.rs (replaces 5 repeated overflow patterns in aws_cmd) - Extract truncate_iso_date() to utils.rs (replaces 2 repeated date- truncation patterns in aws_cmd) - Add output format tests to aws_cmd and psql_cmd using real fixture files Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1071ae8 to
9ec3583
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 aws: Specialized filters for 8 high-frequency AWS CLI commands (STS identity, S3 ls, EC2 describe-instances, ECS list/describe-services, RDS describe-db-instances, CloudFormation list/describe-stacks). Generic fallback forces--output jsonand compresses viajson_cmd::filter_json_string()at depth 4. Achieves 60%+ token savings on verbose AWS table/text output.rtk psql: Detects psql table format (strips----+----borders,(N rows)footer, column padding → tab-separated) and expanded format (-[ RECORD N ]-blocks →[N] key=valone-liners). Passthrough for COPY/SET/notices. Overflow limits: 30 table rows, 20 expanded records.awsandpsqlin distributable and dev hooks.Test plan
cargo fmt --allcleancargo clippy --all-targets— no new warningsrtk aws sts get-caller-identityrtk psql -c "SELECT 1" mydb🤖 Generated with Claude Code