[Feature]: Add --exclude-uri support to ov grep
Problem Statement
When using ov grep on a broad URI scope such as viking://resources, there is currently no convenient way to exclude a specific resource subtree from the search scope.
This makes grep less practical in real-world projects where users often want to:
- search across a large resource tree,
- skip a known noisy subtree such as generated/cache-like content,
- avoid irrelevant matches without changing the resource layout.
For example, if I run grep on viking://resources, I may want to exclude viking://resources/group_a/cache while still searching viking://resources/group_b/cache.
Without an exclusion option, users must either:
- split the search into multiple narrower commands, or
- post-filter results on the client side.
Both approaches are inconvenient and error-prone.
Proposed Solution
Add a new --exclude-uri option to the ov grep command so users can exclude a specific URI subtree from grep matching.
Example:
ov grep --uri viking://resources --exclude-uri viking://resources/group_a/cache "OpenViking"
Expected behavior:
- grep searches under the requested --uri
- any resource whose URI falls under --exclude-uri is skipped
- sibling directories with similar names are not excluded unless they are actually descendants of the excluded URI
This CLI option should be propagated through the existing stack:
- ov grep --exclude-uri
- /api/v1/search/grep request field exclude_uri
- underlying grep/fs implementation
Suggested coverage:
- excluding a single resource path
- excluding a subtree
- ensuring same-named sibling directories are not mistakenly excluded
Alternatives Considered
- Run multiple grep commands on narrower scopes
- Works, but is cumbersome for users
- Pushes filtering complexity into shell scripts or client logic
- Post-filter grep results after the command returns
- Inefficient because the excluded subtree is still searched
- Less intuitive than first-class exclusion support
- Reorganize resources to avoid noisy paths
- Not always realistic
- Users should not have to restructure data just to express search scope
A first-class --exclude-uri option is the most direct and user-friendly solution.
Feature Area
CLI Tools
Use Case
In my project, I want to use ov grep against a large resource tree while excluding specific subtrees that are known to be noisy or irrelevant.
Typical scenarios include:
- searching all project documents except generated/cache-like content
- searching shared resources while excluding one imported subtree
- keeping grep results focused without changing the stored resource structure
This is especially useful when different sibling directories have similar names and only one subtree should be excluded.
Example API (Optional)
CLI example:
ov grep --uri viking://resources --exclude-uri viking://resources/group_a/cache "OpenViking"
Potential HTTP payload behind the CLI:
POST /api/v1/search/grep
{
"uri": "viking://resources",
"pattern": "OpenViking",
"exclude_uri": "viking://resources/group_a/cache"
}
Expected behavior:
- matches under viking://resources/group_a/cache are excluded
- matches under viking://resources/group_b/cache are still returned
Another example:
ov grep --uri viking://resources --exclude-uri viking://resources/exclude.md "OpenViking"
Expected behavior:
- matches from viking://resources/exclude.md are excluded
- matches from other resources under viking://resources are still returned
Additional Context
This feature should define exclusion semantics clearly to avoid accidental over-filtering.
Important edge cases:
- descendants of the excluded URI should be skipped
- unrelated sibling paths should still be searched
- prefix-like names should not be matched incorrectly
For example:
- excluding viking://resources/group_a/cache
- should not exclude viking://resources/group_b/cache
This would make ov grep much more practical for large and structured OpenViking resource trees.
Contribution
- [x] I am willing to contribute to implementing this feature