feat(rewrite): consult user TOML filters as fallback#894
Open
tmchow wants to merge 1 commit intortk-ai:developfrom
Open
feat(rewrite): consult user TOML filters as fallback#894tmchow wants to merge 1 commit intortk-ai:developfrom
tmchow wants to merge 1 commit intortk-ai:developfrom
Conversation
When `registry::rewrite_command()` returns None (no built-in Rust handler), check `toml_filter::find_matching_filter()` before giving up. Commands with user-defined TOML filters (e.g. ssh, jq, just) now get rewritten to `rtk <cmd>` so the hook can route them through the TOML filter engine. Built-in Rust registry retains priority over TOML filters. Fixes rtk-ai#820
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 rewritenow checks user TOML filters when no built-in Rust handler matchesssh,jq,just) get rewritten tortk <cmd>so the hook routes them through the TOML filter engineTest plan
cargo fmt --all -- --checkcargo clippy --all-targetscargo test --all(1131 passed)What changed
In
src/hooks/rewrite_cmd.rs, theNonebranch ofregistry::rewrite_command()now callstoml_filter::find_matching_filter(cmd)before exiting with code 1. If a TOML filter matches, the command is rewritten asrtk <cmd>and printed to stdout with the same permission verdict handling as built-in commands.Three new unit tests verify:
ssh root@host ls(TOML-only) is matched byfind_matching_filterbut not byrewrite_commandhtophas neither registry nor TOML matchgit status(registry command) is handled by the registry, never reaching the TOML fallbackThis contribution was developed with AI assistance (Claude Code).
Fixes #820