-
Notifications
You must be signed in to change notification settings - Fork 1
Description
The register_attachment function calls handler.get individually for each added pattern, which prevents later patterns from overriding earlier patterns and breaks gitignore-style pattern precedence.
Expected Behavior
Pattern precedence should work correctly so that later patterns can override earlier ones. For example:
- First pattern:
foo/(exclude all foo directories) - Second pattern:
!foo/bar.txt(include this specific file)
The second pattern should override the first for the specific file, allowing foo/bar.txt to be included even though foo/ is excluded.
Actual Behavior
The current register_attachment function calls handler.add(uri) followed immediately by handler.get() for each URI individually:
handler.add(uri).await?;
attachments.extend(handler.get(&ctx.workspace.root, ctx.mcp_client.clone()).await?);This means each pattern is processed in isolation, and later patterns cannot override the effects of earlier patterns because handler.get is called before the next pattern is added.
Proposed Solution
Modify the attachment registration process to:
- Call
handler.add()for all patterns first - Call
handler.get()only once after all patterns have been added
This could be achieved by either:
- Modifying
register_attachmentto accept multiple URIs and batch process them - Or creating a new batch registration function that handles multiple attachments at once
- Or modifying the calling code to collect all URIs and call a batch registration function