Skip to content

Fix Intent registry package search - #1079

Merged
tannerlinsley merged 1 commit into
mainfrom
agent/fix-intent-registry-search
Jul 30, 2026
Merged

Fix Intent registry package search#1079
tannerlinsley merged 1 commit into
mainfrom
agent/fix-intent-registry-search

Conversation

@tannerlinsley

@tannerlinsley tannerlinsley commented Jul 30, 2026

Copy link
Copy Markdown
Member

What changed

  • filter npm's package-search response against package name, description, and keywords before merging it into the verified Intent directory
  • ignore the shared tanstack-intent registry marker when matching user queries
  • require every whitespace-separated search term to match package metadata
  • add a focused regression test

Evidence and impact

The npm search API treats keywords:tanstack-intent as sufficient even when the user term does not match. The reported nonsense query returned all 243 Intent-tagged packages, so the UI could not produce an empty or meaningfully narrowed package result. Local filtering preserves npm metadata search while removing unrelated results.

Closes #1070

Validation

  • reproduced the upstream behavior directly against registry.npmjs.org
  • pnpm test — TypeScript, oxlint, and 116 tests: 115 passed, 1 skipped
  • commit hook reran formatting and the same full test gate successfully

Risk

Low. The change only affects non-empty package searches. Matching is intentionally stricter than npm's fuzzy ranking: all entered terms must occur in the package name, description, or non-registry keywords.

Summary by CodeRabbit

  • Improvements

    • Improved package search results by matching queries against package names, descriptions, and relevant keywords.
    • Multi-term searches now return only packages matching all entered terms.
    • Registry-specific keywords are excluded from search matching to reduce unrelated results.
  • Bug Fixes

    • Fixed package listings that could previously include results unrelated to the entered search query.

@tannerlinsley tannerlinsley added the source-audit Tracked by the automated source audit label Jul 30, 2026
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds normalized NPM package search matching, excludes the tanstack-intent keyword from searchable text, applies filtering in getIntentDirectory, and tests positive and negative query behavior.

Changes

NPM search filtering

Layer / File(s) Summary
Package search matcher
src/utils/intent.server.ts, tests/intent-package-search.test.ts
Adds npmPackageMatchesSearch for matching normalized query terms against package metadata and tests matching and exclusion cases.
Directory search integration
src/utils/intent.functions.ts
Filters NPM objects with the matcher before building the directory lookup when a search query is present. Ensures empty searches retain all objects.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and clearly summarizes the main change to Intent registry package search.
Linked Issues check ✅ Passed The new matcher filters npm packages by name, description, and keywords, so unrelated queries no longer return all results.
Out of Scope Changes check ✅ Passed The changes are limited to the search fix and regression test, with no unrelated functionality added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/fix-intent-registry-search

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
tanstack-com 422265c Commit Preview URL

Branch Preview URL
Jul 30 2026, 03:47 PM

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/utils/intent.functions.ts`:
- Around line 207-213: In getIntentDirectory, derive normalizedSearch from
search.trim() once and use it consistently for the NPM request, database lookup,
npmPackageMatchesSearch filtering, and inclusion condition. Replace raw search
checks with normalizedSearch so whitespace-only input follows the empty-search
path and returns all packages.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d1503f48-584e-40e1-8367-8de893a88aed

📥 Commits

Reviewing files that changed from the base of the PR and between cca5c9b and 422265c.

📒 Files selected for processing (3)
  • src/utils/intent.functions.ts
  • src/utils/intent.server.ts
  • tests/intent-package-search.test.ts

Comment on lines +207 to +213
const matchingNpmObjects = search
? npmData.objects.filter((obj) =>
npmPackageMatchesSearch(obj.package, search),
)
: npmData.objects
const npmByName = new Map(
npmData.objects.map((obj) => [obj.package.name, obj]),
matchingNpmObjects.map((obj) => [obj.package.name, obj]),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Normalize the search before branching on it.

npmPackageMatchesSearch treats whitespace-only input as empty, but getIntentDirectory still treats raw search as an active query. A value such as " " can therefore take the filtered/DB-search path and return no packages instead of behaving like an empty search. Derive const normalizedSearch = search?.trim() once and use it consistently for the NPM request, DB lookup, filtering, and inclusion condition.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/utils/intent.functions.ts` around lines 207 - 213, In getIntentDirectory,
derive normalizedSearch from search.trim() once and use it consistently for the
NPM request, database lookup, npmPackageMatchesSearch filtering, and inclusion
condition. Replace raw search checks with normalizedSearch so whitespace-only
input follows the empty-search path and returns all packages.

@tannerlinsley
tannerlinsley merged commit 08cb7eb into main Jul 30, 2026
7 checks passed
@tannerlinsley
tannerlinsley deleted the agent/fix-intent-registry-search branch July 30, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

source-audit Tracked by the automated source audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter search in the Agents Skills Registry does not work

1 participant