Add a general search-entries host tool over the entry endpoint - #6068
Draft
FadhlanR wants to merge 1 commit into
Draft
Add a general search-entries host tool over the entry endpoint#6068FadhlanR wants to merge 1 commit into
FadhlanR wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
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.
Background and Goal
The AI's search capability is split across two narrow host tools that each drop something discovery flows need:
SearchCardsByQueryToolsearches all available realms with a pinned card scope and returns only id/title summaries, andSearchCardsByTypeAndTitleToolcannot express aspecTypeor full-textmatchesfilter at all. This PR adds one generalsearch-entrieshost tool — a thin interface over the/_federated-searchentry endpoint (query + realms + scope + limit in, trimmed entry rows out) — and reroutes the two existing tools' descriptions so the model uses them only when it needs live instances to attach, open, or patch.Where to start
packages/host/app/tools/search-entries.ts— the tool: scope validation, mixed-scope dedup, relevance-sort composition, wire translation, flattening, and the result mapping.packages/base/commands/search-entry-result.gts— the input/result card types (re-exported fromcommand.gts).packages/host/tests/integration/tools/search-entries-tool-test.gts— behavior coverage plus unit-style asserts on the exported query-composition helper.Key decisions and non-obvious mechanics
store.searchEntries, notstore.search— the instances path pinsscope: 'cards'and a data-only fieldset;searchEntriespasses scope/fields/page through untouched and already handles auth, federation, and 429 shed-retries.item.cardTitle,item.cardDescription,item.specType,item.readMe,item.ref): the fieldset stays internal so a caller can never request full serializations.readMereturns in full; the size budget is thelimitinput (default 5, max 10). Tool result cards are inlined verbatim into every subsequent prompt turn with no downstream truncation, so the tool bounds its own output — and the result card usescontainsManysummaries, neverlinksToMany(CardDef).'all'with automatic dedup: a card matches both its instance row and its dual-indexed.jsonfile row under the mixed scope, so the filter gainsexcludeCardInstanceFileRows()unless it already carries a kind-narrowing positive type ref (hasNarrowingPositiveTypeRef, now exported from the host search query-builder rather than copied a third time)._matchRelevancesort is appended only when the filter has a positivematchesterm (the server 400s otherwise), and merged rows are re-sorted client-side because the federated merge concatenates per realm without cross-realm re-ranking.module: '@cardstack/boxel-host/tools/search-entries', name: default. The skill-side declaration lands separately in boxel-skills.Testing
matches, limit defaulting/clamping, realm targeting, and the default-export guard.tools | searchsuite and the host tool schema-generation suite (which now includes the new tool viaHostToolClasses) pass.🤖 Generated with Claude Code