dcdpr / dcdpr/jp

Fix `register_attachment` calling `handler.get` individually preventing pattern precedence

Open
#196 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
16
Forks
3
Avg merge
1d 1h
Merged PRs (30d)
121

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:

  1. Call handler.add() for all patterns first
  2. Call handler.get() only once after all patterns have been added

This could be achieved by either:

  • Modifying register_attachment to 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

Resources

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in crates/jp_cli/src/cmd/attachment.rs:81-106 and inspect register_attachment and its handler.add/handler.get calls. Check the calling path in crates/jp_cli/src/cmd/query.rs:404-406. Done means all patterns are added before one retrieval, allowing later patterns to override earlier ones as in the foo/ and !foo/bar.txt example.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.