# agent: Stop over-escaping dashes in tool_permissions regex patterns \(\#51603\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/a8ca9540666cbb612efdf54a866364a72cc61fdc)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: a8ca9540666cbb612efdf54a866364a72cc61fdc

Requested commit: a8ca9540666cbb612efdf54a866364a72cc61fdc

Commit: a8ca9540666cbb612efdf54a866364a72cc61fdc

Tree: 296db20d3c9c9701e6985513559e318556741ebd

Author: Matt Van Horn

Committer: GitHub

## Message

```
agent: Stop over-escaping dashes in tool_permissions regex patterns (#51603)

Fixes #51537

`regex::escape()` escapes dashes, but dashes are only special inside
`[]` character classes in regex. This means tool_permissions patterns
end up with unnecessary backslashes:

**Before:** `^https?://typescript\-eslint\.io`, `^git\-lfs\s+pull(\s|$)`
**After:** `^https?://typescript-eslint\.io`, `^git-lfs\s+pull(\s|$)`

The fix adds a small `escape_for_pattern()` helper that calls
`regex::escape()` then strips the unnecessary dash escaping via
`.replace("\\-", "-")`. This is applied to all five call sites in
`pattern_extraction.rs`.

Tests updated to expect unescaped dashes, plus a new
`test_dashes_are_not_escaped` test covering terminal commands, URLs, and
paths with dashes.

This PR was developed with AI assistance.

Release Notes:

- Fixed unnecessary escaping of dashes in agent tool permission patterns
(e.g. `typescript\-eslint` is now `typescript-eslint`)

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
```

## Parents

- [3db5c398a2bcbdd824854e895f2d275709b9b948](https://git.cafe/gitcafe/zed/commit/3db5c398a2bcbdd824854e895f2d275709b9b948?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/a8ca9540666cbb612efdf54a866364a72cc61fdc?format=markdown)
