Shell permission refusal: name the part that the host denied
Summary
When the host denies a shell command that has more than one part, the refusal names all the parts. It does not name the part that the host denied. The agent and the user then cannot see which part to change.
What occurs
withBashPermissionLoop (packages/aft-bridge/src/bash-permissions.ts) sends all the parts of one command in one permission.assert call. On a deny, it builds the message from all the pending parts and the host's message:
Permission denied for this shell command: <part 1>, <part 2>, <part 3> (Permission denied: shell). The parts are checked together, so one denied part denies the whole command; run the allowed parts in a separate call.
Example: an agent role lets the agent run git show but not git ls-tree. A host plugin adds a setup part in front of each command. The agent runs a command with the setup part and git ls-tree.
The refusal shows the setup part first, then git ls-tree. The host denied only the git ls-tree part, but the text does not show this. A reader can think that the setup part caused the refusal. We made this mistake one time.
The text is the same in v0.65.0 and on main today.
Request
Name the denied part, for example:
Permission denied for this shell command: the host denied `git ls-tree HEAD src` (Permission denied: shell). The other parts were not denied: <part 1>. The parts are checked together, so one denied part denies the whole command; run the allowed parts in a separate call.
Possible procedures
- On OpenCode 2, a deny from
permission.assertis aPermission.BlockedError(packages/core/src/permission.tsin OpenCode). That error hasresources, which are all the parts, andrules, which are the configured rules for the permission. AFT reads onlyerror.message. AFT can find the parts that a deny rule agrees with, and name them. - Or, after a deny of a command with more than one part, AFT can check each part alone. Then it can name the parts that the host denies.
If the host does not give sufficient data to find the part, please change the text to "one or more of these parts was denied". Then no reader thinks that the first part is the denied part.
Thanks for the clear report and the reproduction. Confirmed: today the refusal lists every part of the command and doesn't say which one the host denied.
We'll fix it as you suggest. On OpenCode 2 we read the deny rules carried by Permission.BlockedError and name the part they match, plus the parts that weren't denied. Where the host gives no rule data (OpenCode 1, Pi), the text will say "one or more of these parts was denied" instead of implying the first part. We won't re-check each part on its own, because that could show several permission prompts for one command.
This will ship in an upcoming release; we'll update this issue when it's published.
Fixed in v0.66.0: a shell permission refusal now names the part of the command the host denied. Thanks for the suggestion, @iceteaSA.