Skip to content

feat(search): path_excludes filter + teach the MCP keyword-OR / noise-dir exclusion#471

Merged
githubrobbi merged 1 commit into
mainfrom
feat/mcp-path-excludes-and-search-instructions
Jun 22, 2026
Merged

feat(search): path_excludes filter + teach the MCP keyword-OR / noise-dir exclusion#471
githubrobbi merged 1 commit into
mainfrom
feat/mcp-path-excludes-and-search-instructions

Conversation

@githubrobbi

Copy link
Copy Markdown
Collaborator

Why

An LLM was asked "find my solar/energy spreadsheets" and (a) hallucinated CLI flags, (b) ran 8 separate searches (one per keyword), and (c) claimed "UFFS MCP doesn't have path-exclude." Two real causes:

  1. Teaching gap — regex-OR and the existing filters (exclude, match_path) weren't in the agent instructions.
  2. Capability gapexclude matches the filename, path_contains is a positive include, so there was genuinely no way to drop noise directories (.cargo, AppData, …). The agent was right.

What this does

Capability — new path_excludes

A comma-separated list of directory-path globs; a record is dropped when its directory matches any entry (inverse of path_contains, multi-value so several noise dirs go in one query). Wired end-to-end:
SearchParams (protocol) → SearchFilters (core; parsing in path_normalize::parse_path_excludes — comma-split, lowered, separator-normalized) → daemon → MCP uffs_search tool → --not-in-path CLI flag mirroring --in-path.

Teaching — AGENT_INSTRUCTIONS

  • KEYWORD-OR with ONE regex >(a|b|c) (case-insensitive), never N searches;
  • path_excludes (noise dirs), exclude (filename glob), match_path;
  • documents collection covers xls/xlsx;
  • a worked "topic files in a folder, minus dev noise" one-call example.

So the failure becomes:

uffs_search pattern='>(solar|energy|utility|pge|sunrun)' ext='xls,xlsx' \
  path_contains='Users\\name' path_excludes='*appdata*,*.cargo*,*.rustup*'

Tests / verification

from_params_path_excludes_* (comma-split / lowercase / normalize / None-on-blank). macOS + x86_64-pc-windows-msvc builds + clippy clean; full pre-push gate green. filters/mod.rs (cohesive struct + from_params) registered in file_size_exceptions.txt as it crosses the 800-LOC line.

🤖 Generated with Claude Code

…-dir exclusion

Agents kept doing "find files about X" badly — N separate searches (one per
keyword) and hand-stacked excludes — and even claimed the MCP "doesn't have
path-exclude". Two real causes: (1) a teaching gap (regex-OR and the existing
filters weren't in the agent instructions), and (2) a genuine capability gap —
`exclude` matches the FILENAME, `path_contains` is a positive include, and
there was no way to drop noise DIRECTORIES.

This fixes both.

Capability — new `path_excludes`: a comma-separated list of directory-path
globs; a record is dropped when its directory matches ANY entry (inverse of
`path_contains`, multi-value so several noise dirs go in one query). Wired
end-to-end: protocol `SearchParams` → core `SearchFilters` (parsing extracted to
`path_normalize::parse_path_excludes`) → daemon → MCP `uffs_search` tool, plus a
`--not-in-path` CLI flag mirroring `--in-path`.

Teaching — AGENT_INSTRUCTIONS now spell out:
• KEYWORD-OR with ONE regex `>(a|b|c)` (case-insensitive), never N searches;
• `path_excludes` for noise dirs, `exclude` (filename glob), `match_path`;
• the `documents` collection covers xls/xlsx;
• a worked "topic files in a folder, minus dev noise" one-call example.

filters/mod.rs is at the 800-LOC boundary; the new field tips it over, so it is
registered in file_size_exceptions.txt (cohesive struct + from_params).

Tests: `from_params_path_excludes_*`. macOS + windows-msvc builds + clippy clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@githubrobbi githubrobbi enabled auto-merge (squash) June 22, 2026 04:39
@githubrobbi githubrobbi merged commit 5463784 into main Jun 22, 2026
21 checks passed
@githubrobbi githubrobbi deleted the feat/mcp-path-excludes-and-search-instructions branch June 22, 2026 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant