Skip to content

Comments

feat: add AWS CLI and psql modules#216

Open
itai-sagi wants to merge 3 commits intortk-ai:masterfrom
itai-sagi:feat/aws-psql-support
Open

feat: add AWS CLI and psql modules#216
itai-sagi wants to merge 3 commits intortk-ai:masterfrom
itai-sagi:feat/aws-psql-support

Conversation

@itai-sagi
Copy link

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 json and compresses via json_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=val one-liners). Passthrough for COPY/SET/notices. Overflow limits: 30 table rows, 20 expanded records.
  • Hook rewrite patterns added for both aws and psql in distributable and dev hooks.

Test plan

  • 32 new inline tests (16 aws_cmd + 16 psql_cmd) all passing
  • Full test suite: 428 tests pass, 0 failures
  • cargo fmt --all clean
  • cargo clippy --all-targets — no new warnings
  • Manual test with real AWS CLI (if configured): rtk aws sts get-caller-identity
  • Manual test with real psql (if available): rtk psql -c "SELECT 1" mydb

🤖 Generated with Claude Code

itai.sagi and others added 3 commits February 19, 2026 15:54
Add two new command modules:

- `rtk aws`: Specialized filters for STS, S3, EC2, ECS, RDS, and
  CloudFormation commands. Generic fallback forces --output json and
  compresses via json_cmd schema extraction. Achieves 60%+ token savings
  on verbose AWS table/text output.

- `rtk psql`: Detects table format (strips borders, separators, row
  counts, outputs tab-separated) and expanded format (converts
  -[ RECORD N ]- blocks to compact key=val one-liners). Passthrough
  for COPY/SET/notices.

Both modules include 32 inline tests covering all filters, edge cases,
overflow limits, and token savings verification.

Hook rewrite patterns added for both distributable and dev hooks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Piped (cmd | grep), chained (cmd && cmd), and redirected (cmd > file)
commands are no longer rewritten by the hook — the output is being
processed by the next command, not shown to the LLM, so filtering
would break the pipeline.

RTK.md updated with guidance on when to use `rtk proxy` for raw
unfiltered output (parsing specific fields, scripting, debugging).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pszymkowiak
Copy link
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
before merge:

Critical

  1. Revert commit polluting the PR: There's a revert commit that adds noise to the diff. Please clean up the git history (interactive rebase) so only AWS/psql changes are included.
  2. run_generic --output injection: The --output json flag is injected into all AWS commands via run_generic, but not all AWS subcommands support --output. This could break commands like
    aws s3 cp or aws s3 sync. Consider only injecting --output json for commands that support structured output (describe, list, get, etc.), or catch the error and fallback to raw execution.
  3. psql tracking on failed commands: Token savings are recorded even when the psql command fails (non-zero exit code). Tracking should only happen on successful executions to avoid
    skewing metrics.

Improvements

  1. Duplicate lazy_static! blocks: Several identical regex patterns are defined in multiple lazy_static! blocks across both modules. Factor them into shared constants or a single block.
  2. Test fixtures should use real command output: Per project guidelines (see CLAUDE.md > Testing Strategy), tests should use include_str!("../tests/fixtures/...") with real command
    output, not synthetic/hardcoded strings. This ensures filters work against actual CLI output formats.
  3. Token savings threshold too low: Tests assert ≥30% savings, but RTK's project standard is ≥60%. Please raise the threshold or justify why these specific filters have lower savings
    expectations.

Minor

  • Consider adding snapshot tests (assert_snapshot!) for output format validation
  • AWS module is +845 lines — could some shared patterns (JSON flattening, table formatting) be extracted to utils.rs?

Overall solid work, looking forward to the next iteration! 🔧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants