feat(az): add Azure CLI filter support (pipelines, devops, account)#1209
Open
lucachitayat wants to merge 2 commits intortk-ai:developfrom
Open
feat(az): add Azure CLI filter support (pipelines, devops, account)#1209lucachitayat wants to merge 2 commits intortk-ai:developfrom
lucachitayat wants to merge 2 commits intortk-ai:developfrom
Conversation
Add token-optimized output for Azure CLI commands: - az pipelines build list/show — compact build summary table - az devops invoke --resource timeline — failed tasks only with logIds - az devops invoke --resource logs — timestamp stripping, tail last N - az account get-access-token — token value extraction - Generic JSON compression fallback for all other az subcommands Measured savings in a .NET monorepo: - az pipelines build list: 99.1% reduction (7KB → 70B per build) - az devops invoke timeline: 99.7% reduction (81KB → 250B) - az account get-access-token: ~90% reduction Includes rewrite rule, 11 unit tests, and CLI enum registration. Closes rtk-ai#1208
… tests - Fix --output= equals syntax detection (was injecting duplicate flags) - Remove double stderr on error (run_az_json + caller both printed) - Propagate exit codes on success path (was always returning 0) - Mask JWT in filter_access_token (credential leak to LLM context) - Enrich filter_build_show with branch, commit, reason, requester, duration - Enrich filter_build_list with buildNumber and reason per line - Enrich filter_timeline with all tasks, error counts, issue messages, durations - Move TIMESTAMP_RE to module-level lazy_static - Combine stdout+stderr in run_az_text_filtered tee path - Add 14 new tests: token savings assertions + edge cases (25 total)
Author
|
Hey @aeppling — the CI workflow is stuck at 👉 https://github.com/rtk-ai/rtk/actions/runs/24272093000 Thanks! |
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.
Scope
Add token-optimized output filters for Azure CLI (
az) commands. RTK supportsawsbut had no Azure equivalent — this adds the same pattern foraz.Closes #1208
Implementation
Follows the exact architecture of
aws_cmd.rs: CLI enum registration, rewrite rule inrules.rs, and a newaz_cmd.rshandler insrc/cmds/cloud/.Specialized filters (5 handlers):
az pipelines build list— compact one-liner per build with id, buildNumber, pipeline, result, branch, reason, dateaz pipelines build show— multi-line build card with branch, commit SHA, reason, requester, chrono-computed durationaz devops invoke --resource timeline— all tasks with durations; failed tasks show errorCount, warningCount, and first issue messageaz devops invoke --resource logs— strips timestamps, tails last 50 linesaz account get-access-token— masks JWT (10-char prefix only), shows subscription/tenant/expiry metadataGeneric fallback — forces
--output jsonand appliesjson_cmd::filter_json_string()for any unhandledazsubcommand.Hardening Pass (post-review)
5 bugs fixed, 1 security issue resolved, 3 filters enriched, 14 tests added:
--output=detection--output=table) was not detected, causing duplicate flag injectionrun_az_jsonand callers both printed stderr on error — now prints onceBearer [eyJ0eXAiOi...]prefix onlyrun_az_text_filteredwasn't combining stdout+stderr for tee recoverylazy_staticplacementTIMESTAMP_REmoved from function body to module level per conventionReal-world test results (production Azure DevOps)
az pipelines build list --top 5az pipelines build show --id 295493az devops invoke --resource timeline(57 tasks)az account get-access-tokenExample filtered output — build show:
Example filtered output — timeline (truncated):
Notable Changes
src/cmds/cloud/az_cmd.rs— 1,501 lines. Core filter logic + 25 unit tests (5 token savings, 9 edge cases, 11 functional).src/main.rs—Azvariant added toCommandsenum + dispatch.src/discover/rules.rs— Rewrite rule for^az\s+with per-subcommand savings estimates.