Repository navigation
Conversation
…ailable codesearch matches text, not code structure. The OpenCode plugin now adds one routing line to its injected guidance (and one alternative line to the block-mode denial) naming ast-grep tools, but only when the request's tool map actually contains them: ast-grep is not a codesearch dependency and upstream users are not expected to have it installed, so every mention is gated on astGrepToolNames(event.tools) and environments without an ast-grep integration see unchanged guidance. Coverage: unit tests for the name detection; smoke tests pin the guidance line and the block message both with and without ast-grep in event.tools.
…ugin ast-grep routing hints, upstream PR flupkede#302)
flupkede
left a comment
There was a problem hiding this comment.
Clean addition — the availability-gating is exactly the right discipline (nothing to install, no phantom tools, block mode only names callable tools), and the negative-tested gate is the kind of proof this plugin's warnings channel deserves.
One wording caveat, non-blocking: the guidance line reads "For syntax-shaped queries and multi-file mechanical rewrites, prefer the ast-grep tools". The second half is squarely ast-grep territory (we have no rewrite capability and don't want one — that's the agent's job). But "syntax-shaped queries" invites routing query traffic away from codesearch: "which call sites use X" is find_impact's precise answer, and concept/symbol queries belong to codesearch search. Suggest narrowing the line to the rewrite case ("For multi-file mechanical rewrites, prefer ...") — or keeping queries in but explicitly deferring to find_impact first.
For context: we're considering native structural-pattern search (ast-grep-core as a library, no external install) as a future codesearch tool — if that lands, the guidance gains a codesearch-first line and this gate composes naturally (external ast-grep remains the rewrite path). Not a dependency of this PR; merging it as-is is fine.
Resolve the CHANGELOG conflict: the ast-grep routing entry moves to the current pending heading (1.6.1) on top of develop's 1.6.0 release notes.
Summary
codesearch matches text, not code structure. The OpenCode plugin now adds one routing line to its injected guidance (and one alternative line to the block-mode
grepdenial) naming ast-grep tools such asast_grep_search/ast_grep_edit— only when the request's tool map actually contains them.ast-grep is not a codesearch dependency and users are not expected to have it installed. Every mention is gated on
astGrepToolNames(event.tools), the assembled per-request tool map that is only visible in the context hook, so:grepwhile pointing at a tool that does not exist;Tests
test/unit.ts—astGrepToolNamesdetection: absent/null/non-object maps, non-ast-grep tools,ast_grep_*andast-grep_*names, tool-map order.test/smoke.ts— guidance omits ast-grep without it and names it with it; the block denial omits it for sessions that never exposed it and names it otherwise.npm test(typecheck + unit + smoke) is green; the gating smoke assertion was verified to fail with the gate removed.A CHANGELOG entry is included under the pending heading.