feat: add rtk cdk diff/synth/deploy filters - #402
ThomasHoussin wants to merge 2 commits into
Conversation
Merge fork/feat/yarn-cmd-v2 (PR rtk-ai#317) into local branch based on feat/cdk-cmd (PR rtk-ai#402). Resolved 3 conflicts: - registry.rs: kept both gh and yarn rewrite tests, added CDK rewrite tests - tsc_cmd.rs: kept has_program() from windows-compat branch - utils.rs: kept has_program() + script_cmd with concise doc Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4ebec65 to
a7a4daa
Compare
dc20fc4 to
cc93afc
Compare
|
Hey We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes No logic changes — only file moves and import path updates. What you need to doRebase your branch on git fetch origin && git rebase origin/developGit detects renames automatically. If you get import conflicts, update the paths: use crate::git; // now: use crate::cmds::git::git;
use crate::tracking; // now: use crate::core::tracking;
use crate::config; // now: use crate::core::config;
use crate::init; // now: use crate::hooks::init;
use crate::gain; // now: use crate::analytics::gain;Need help rebasing? Tag @aeppling |
Rebased onto develop (post PR rtk-ai#826 folder reorganization). Implements rtk cdk with 3 specialized whitelist filters: - diff: keeps stack headers, resource diff markers, IAM tables, summary - synth: dual-path (no-template: stack list, template: resource types) - deploy: strips per-resource progress lines, keeps success/failure/outputs Handles Windows/PowerShell mojibake (box-drawing characters). Token savings: 72-99% across 6 fixtures. Adapted for develop folder structure: - cdk_cmd.rs placed in src/cmds/cloud/ - script_cmd() replaced with resolved_command() from core::utils - has_program() replaced with tool_exists() - crate::tee:: replaced with crate::core::tee:: - Fixture include paths updated for new depth - Snapshots regenerated with correct module paths 32 unit tests (6 snapshot). 1173 total tests passing. Original-PR: rtk-ai#402 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add #[command(alias = "synthesize")] on CdkCommands::Synth so `rtk cdk synthesize` routes to the synth filter (was passthrough) - Mark destroy/bootstrap as RtkStatus::Passthrough in discover rules so `rtk discover` doesn't claim 75% savings for unfiltered commands Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
a7a4daa to
650741d
Compare
Rebased onto
|
| Fixture | Input | Output | Savings |
|---|---|---|---|
| cdk_diff_raw | 870 | 240 | 72% |
| cdk_diff_raw_1 | 1049 | 133 | 87% |
| cdk_synth_raw | 483 | 10 | 98% |
| cdk_synth_raw_1 | 2374 | 23 | 99% |
| cdk_deploy_raw | 334 | 20 | 94% |
| cdk_deploy_raw_1 | 396 | 13 | 97% |
Test results: 32 unit tests (6 snapshot). 1173 total tests passing (0 failures).
All filter logic, whitelist approach, and mojibake handling are unchanged from the original PR.
|
This pull request has been automatically marked as stale due to 90 days of inactivity. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. Your contribution is very much appreciated — we're sorry we haven't been able to review it yet. |
|
Closing this pull request after a prolonged period of inactivity. If this is still relevant, please ask for it to be reopened. Thank you! |
Context
AWS CDK is an Infrastructure-as-Code framework. Its CLI commands (
cdk diff,cdk synth,cdk deploy) produce extremely verbose output: asset bundling logs (esbuild, Docker, pip), CloudFormation progress lines, NOTICES sections, and full YAML templates. A typicalcdk diffon a project with 13 lambdas generates ~870 tokens of which only ~240 are meaningful.What this PR does
Adds
rtk cdkwith 3 specialized filters:rtk cdk diff— Keeps only stack headers, resource diff markers ([+]/[-]/[~]), IAM change tables, and a summary count. Strips all bundling noise, build logs, and NOTICES.rtk cdk synth— Two modes: when no stack is specified, shows the synthesized path + stack list. When a full YAML template is output, extracts a resource type summary (e.g. "Lambda::Function x7, IAM::Role x10").rtk cdk deploy— Strips per-resource CloudFormation progress lines, keeps success/failure status, outputs section, and timing. Handles both standard and stack-prefixed progress formats.Design: whitelist approach — only keep lines matching known meaningful patterns. Everything else is dropped. This is future-proof: any new bundler or tool CDK adds will be automatically filtered without code changes.
Handles Windows/PowerShell mojibake (box-drawing characters rendered as
Ôö£ÔöÇinstead of├──).Token savings
Depends on
Based on #398 (
fix/windows-cmd-compat) —cdk_cmd.rsusesscript_cmd()required for Windows wherecdkis a.ps1wrapper. Will rebase onto master once #398 is merged.Test plan
cargo fmt && cargo clippy --all-targets && cargo test --all— 745 tests pass🤖 Generated with Claude Code