npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ai-search-core

v1.0.0

Published

A generic, context-aware AI search engine library for any domain.

Downloads

81

Readme

AI Search Core Library 🧠

A Context-Aware, Intent-Driven Search Engine designed for any domain (E-commerce, Travel, SaaS, etc.).

This library provides a flexible "brain" for your search bar. Unlike standard search engines (Algolia, Fuse.js) that only match text, AI Search Core understands:

  1. Context: Remembers what the user just saw or asked.
  2. Intent: Detects if user wants to "buy", "compare", or "find info".
  3. Preferences: Boosts results based on user stats (e.g., "Apple fan", "Budget shopper").

Installation

npm install ai-search-core fuse.js

Quick Start

1. Define your Data

Your data can be anything. We just need a standard structure to index.

const products = [
  { id: 1, title: 'iPhone 15', category: 'Smartphone', price: 999 },
  { id: 2, title: 'MacBook Air', category: 'Laptop', price: 1200 },
  { id: 3, title: 'Samsung S24', category: 'Smartphone', price: 899 },
];

2. Configure the Brain

Define how the AI should "think".

import { CoreEngine, AIConfig } from 'ai-search-core';
import Fuse from 'fuse.js';

const config: AIConfig = {
    // 1. Synonym Mapping
    synonyms: {
        'hp': ['smartphone', 'phone', 'mobile'],
        'mac': ['macbook', 'laptop']
    },

    // 2. Define Intents (What is the user trying to do?)
    intents: [
        { name: 'check_price', patterns: ['how much', 'price', 'cost', 'biaya'] },
        { name: 'compare', patterns: ['vs', 'difference', 'compare', 'beda'] }
    ],

    // 3. Boosting Rules (Business Logic)
    boostingRules: [
        // Rule: If asking for price, boost items with prices displayed
        { 
            condition: (item, ctx, intent) => intent === 'check_price' && item.price > 0,
            score: 20 
        },
        // Rule: If user is an "Apple Fan" (tracked in context), boost Apple products
        {
            condition: (item, ctx) => ctx.userPreferences.brand === 'Apple' && item.title.includes('iPhone'),
            score: 50 
        }
    ]
};

3. Initialize & Search

const engine = new CoreEngine(products, Fuse, config);

// Simulation
const result = engine.search("berapa harga hp?");

console.log(result.intent); // 'check_price'
console.log(result.results); // [iPhone 15, Samsung S24, ...] (Boosted by intent)

Advanced Features

Context Memory

The engine remembers the conversation turn-by-turn.

// Turn 1
engine.search("Lihat iPhone 15"); 
// Engine remembers: lastTopic = 'Smartphone', lastItem = 'iPhone 15'

// Turn 2 (Follow-up)
engine.search("Warnanya apa aja?");
// Engine knows "Warnanya" refers to "iPhone 15" from previous turn.

Setting User Preferences Dynamically

You can feed external signals into the engine (e.g., from buttons or user profile).

// User clicked "Apple" filter button in UI
engine.setPreference('brand', 'Apple');

// Next search will heavily boost Apple products due to the BoostingRule we defined above.
engine.search("laptop terbaik"); // -> MacBook will be top result

API Reference

CoreEngine

  • constructor(data, FuseClass, config)
  • search(query: string): SearchResult
  • setPreference(key, value): void

AIConfig

  • synonyms: Record<string, string[]>
  • stopWords: string[]
  • intents: IntentDefinition[]
  • boostingRules: BoostingRule[]

License

MIT