feat: reject complex chains that require approval with readability instruction - #15
Merged
Merged
Conversation
…struction
When a bash command has multiple top-level chain segments (&&, ||, ;, |)
and the resolved permission would be 'ask', the plugin now rejects the
command with a heredoc message telling the agent to rewrite it with
newlines and comments for readability.
- Add topLevelSegments to ChainResult to distinguish top-level chains
from nested substitutions (, backticks, eval, sh -c)
- Returns readabilityReject=true and stores deny decision for complex
ask commands
- Replaces the command with a heredoc error message instead of wrapping
in { ... ; }
- 18 new tests covering isComplexChain, readability rejection logic,
and buildReadabilityMessage
👀 AI Code ReviewThe implementation introduces measures to reject complex chains requiring approval, enhancing readability. Tests are comprehensive and cover all new functionality. Couldn't place inline comments for:
Powered by GPT-4o via GitHub Models |
Owner
Author
|
The The existing tests already cover the boundary:
No missing test case here. |
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.
When a bash command has multiple top-level chain segments (
&&,||,;,|) and the resolved permission would beask, the plugin now rejects the command with a heredoc message telling the agent to rewrite it with newlines and comments for readability.Changes
topLevelSegmentstoChainResult— distinguishes top-level chains from nested substitutions ($(), backticks,eval,sh -c)isComplexChain(),buildReadabilityMessage()exports;beforeExecutenow returnsreadabilityReject=trueand storesdenyfor complex ask commandsreadabilityRejectis true, replaces the command with a heredoc formatting error instead of wrapping in{ ... ; }isComplexChain, readability rejection flows,buildReadabilityMessageTesting