feat(scripted-tool): add --dry-run flag with pluggable validation#1293
Merged
feat(scripted-tool): add --dry-run flag with pluggable validation#1293
Conversation
When --dry-run is passed, ScriptedTool validates arguments against the schema without executing the callback. Returns structured JSON result. Custom dry-run handlers can be registered per-tool via tool_with_dry_run(). Also adds --help flag interception (same output as `help <tool>`). Closes #1279
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
--dry-runflag that validates arguments without executing the callbacktool_with_dry_run()builder method for custom dry-run handlers--helpflag interception (same output ashelp <tool>)Details
When
--dry-runis passed, the tool:--dry-runfrom args before parsing{"dry_run":true,"valid":true,"tool":"name","params":{...}}{"dry_run":true,"valid":false,"tool":"name","error":"..."}Custom dry-run handlers can be registered per-tool via
tool_with_dry_run()for domain-specific validation (e.g. checking if a resource exists before mutating it).--helptakes precedence over--dry-runwhen both are present.Test plan
test_dry_run_validates_args— validates args and returns structured JSONtest_dry_run_does_not_invoke_callback— fail_tool --dry-run succeedstest_dry_run_help_precedence— --help takes precedencetest_custom_dry_run_handler— custom handler is calledtest_help_flag_returns_help— --help returns help textCloses #1279