Nico Albanese b09f77ffef
Allow path-glob approval rules to match outside working directory (#80)
* Fix read tool approval rules not persisting across turns

The read tool was not checking saved approval rules, causing users to be
re-prompted for file reads even after selecting "don't ask again".

Additionally, pathMatchesGlob had a boundary check that prevented matching
paths outside the working directory, but read approval rules specifically
apply to files outside the working directory.

Changes:
- Add approval rule checking to read tool's needsApproval function
- Add allowOutsideBase option to pathMatchesGlob for read rules

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix glob and grep approval rules for paths outside working directory

Same issue as the read tool fix: pathMatchesGlob was returning false for
paths outside the working directory, preventing approval rules from matching.

Added allowOutsideBase: true to both tools' pathMatchesApprovalRule functions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Allow write/edit approval rules to work for paths outside working directory

Previously, write and edit operations outside the working directory would
always require approval, ignoring any saved approval rules. Now approval
rules are checked first, allowing users to select "don't ask again" for
writes/edits outside the working directory.

Changes:
- Check approval rules before checking if path is outside working directory
- Use allowOutsideBase: true in pathMatchesGlob for write/edit rules

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Update ApprovalRule comment to reflect outside-cwd support

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 21:23:10 +00:00
..
2026-01-09 16:10:49 +01:00