Skip to content

fileRegex for @ file references within custom commands is far too inclusive #2198

@aspiers

Description

@aspiers

I'm trying to write a custom /commit command, and I have as part of it:

   - Adds a "Co-authored-by:" footer which clarifies which AI agent
     helped create this commit, using an appropriate `noreply@...`
     email address.

This causes opencode to attempt to find a file called ... which is clearly wrong! I see that the regex used doesn't take into account what precedes the regex:

const fileRegex = /@([^\s]+)/g

I think a reasonable solution is to use a negative look-behind assertion: https://regex101.com/r/F6KAgH/1

I will submit a PR shortly.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions