feat(explore): Bash intercept, semantic output, robust citation resol…#8
Merged
HeinrichvH merged 1 commit intomainfrom Apr 22, 2026
Merged
feat(explore): Bash intercept, semantic output, robust citation resol…#8HeinrichvH merged 1 commit intomainfrom
HeinrichvH merged 1 commit intomainfrom
Conversation
…ution
Fold recipes/explore-goose/ into recipes/explore/ as the single, concrete
explorer recipe; README documents the Goose+Devstral reference impl and
how to swap backends.
Intercept leading Bash search commands (grep/egrep/fgrep/rg/find/fd/ag/ack,
optionally preceded by env assignments) and route them to the explore
worker. Piped filters like `kubectl ... | grep foo` are correctly skipped
because the explorer can't reproduce the upstream command's output. `ls`
is deliberately omitted — too often a one-shot sanity check where routing
burns latency for no context win. Session log analysis showed this
intercept addresses ~9% of all Bash calls, clustered into exploration
episodes that collapse from ~3k tokens to one ~250-token subagent report
when the semantic answer suffices.
Two mechanical robustness fixes in explore.py so the subagent stays
useful across repo layouts and cwd drift:
- resolve_cited_path: when `repo_root / cited_path` doesn't exist,
suffix-match against `git ls-files` and accept only a unique hit.
Handles the common case where the subagent drops a monorepo prefix
(cites `Core/Foo.cs` instead of `src/Core/Foo.cs`). Ambiguous
matches (e.g. multiple `README.md`) are rejected rather than silently
picked.
- derive_repo_root: absolute paths in the query are the authoritative
scope signal. When Claude greps an absolute path outside cwd (e.g.
another checkout from a different project dir), use that path's git
toplevel — not the cwd-derived one. Fallback to cwd's toplevel only
when the query has no absolute paths.
Trim the Claude-facing response to keep context lean:
- _validation block moves to stderr — it's debug telemetry Claude can't
act on; the operator still sees it in the transcript.
- references whose citation already appears in findings are dropped
(dedup); the references array is omitted entirely when it would be
empty.
- empty findings arrays are dropped.
- json.dumps emits compact single-line output; saves ~15-20% whitespace.
- resolved_path attached to findings when suffix-matching kicked in, so
Claude can Read the real path without re-guessing the prefix.
Semantic prompt changes in goose-home/explore/recipe.yaml push the
subagent from enumerating occurrences ("used in X, used in Y, used in Z")
to interpreting them ("sentinel identity for platform-level operations
when caller context is missing, used in messaging, AI proxy, user mgmt").
Grouping rule: one finding per semantic role, not one per citation. The
references array is now truly optional — populate only when a related
location is worth calling out.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fold recipes/explore-goose/ into recipes/explore/ as the single, concrete explorer recipe; README documents the Goose+Devstral reference impl and how to swap backends.
Intercept leading Bash search commands (grep/egrep/fgrep/rg/find/fd/ag/ack, optionally preceded by env assignments) and route them to the explore worker. Piped filters like
kubectl ... | grep fooare correctly skipped because the explorer can't reproduce the upstream command's output.lsis deliberately omitted — too often a one-shot sanity check where routing burns latency for no context win. Session log analysis showed this intercept addresses ~9% of all Bash calls, clustered into exploration episodes that collapse from ~3k tokens to one ~250-token subagent report when the semantic answer suffices.Two mechanical robustness fixes in explore.py so the subagent stays useful across repo layouts and cwd drift:
resolve_cited_path: when
repo_root / cited_pathdoesn't exist, suffix-match againstgit ls-filesand accept only a unique hit. Handles the common case where the subagent drops a monorepo prefix (citesCore/Foo.csinstead ofsrc/Core/Foo.cs). Ambiguous matches (e.g. multipleREADME.md) are rejected rather than silently picked.derive_repo_root: absolute paths in the query are the authoritative scope signal. When Claude greps an absolute path outside cwd (e.g. another checkout from a different project dir), use that path's git toplevel — not the cwd-derived one. Fallback to cwd's toplevel only when the query has no absolute paths.
Trim the Claude-facing response to keep context lean:
Semantic prompt changes in goose-home/explore/recipe.yaml push the subagent from enumerating occurrences ("used in X, used in Y, used in Z") to interpreting them ("sentinel identity for platform-level operations when caller context is missing, used in messaging, AI proxy, user mgmt"). Grouping rule: one finding per semantic role, not one per citation. The references array is now truly optional — populate only when a related location is worth calling out.