aft icon indicating copy to clipboard operation
aft copied to clipboard

grep and glob tools: forward exclude to the module

Open iceteaSA opened this issue 5 days ago • 1 comments

Summary

The module's grep command accepts an exclude list, but the OpenCode grep tool does not forward it. The glob command and tool have no exclude field.

Source locations (v0.68.0 source and the @cortexkit/aft-opencode 0.68.1 package)

  • crates/aft/src/commands/grep.rs:161-162 reads include and exclude from the request.
  • packages/opencode-plugin/src/tools/search.ts:205-208: the grep tool sends only pattern, include, path and offset. The published 0.68.1 dist/index.js has the same code, and the tool's argument schema has no exclude.
  • packages/opencode-plugin/src/tools/search.ts:314-315: the glob tool sends only pattern and path.
  • crates/aft/src/commands/glob.rs:51,80: the glob command reads only pattern and path.

Effect

A host plugin that applies read rules to search results can only remove denied matches after the search. Those matches use the result cap, the ranking and the truncation. When a denied subtree has many matches, a search can give fewer permitted matches than it could, or none. If the plugin can set exclude before the call (for example in its tool.execute.before hook), the module skips the denied subtrees before it counts and ranks.

Request

  1. Forward an exclude argument from the grep tool to the module when the argument is set. An entry in the tool schema is optional, because a host hook can set the argument.
  2. Add the same exclude field to the glob command and the glob tool.

iceteaSA avatar Nov 28 '26 21:11 iceteaSA

Thanks for tracing this through both the module and the plugin.

Rather than a new argument, grep's include and glob's pattern will accept ! entries in their comma-separated lists, the way ripgrep's -g '!…' does, on every host. For example, include: "**/*.ts,!**/vendor/**". Excluded paths are skipped during the walk, before matches are counted, capped and ranked, which is the ordering you're after. A plugin hook that adds a ! entry before the call gets the same result. It's queued for an upcoming release.

aft-alfonso[bot] avatar Dec 02 '26 21:12 aft-alfonso[bot]