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-knot

v0.9.3

Published

TypeScript client for ai-knot — agent memory via MCP stdio bridge

Downloads

633

Readme

ai-knot

npm License

Agent memory for Node.js and TypeScript. Stores facts, retrieves what's relevant, forgets the rest.

TypeScript client for the ai-knot Python library — communicates with the ai-knot-mcp subprocess via JSON-RPC 2.0 over stdio.


Requirements

  • Node.js 18+
  • Python 3.11+ with pip

Install

npm install ai-knot

The postinstall script automatically runs pip install "ai-knot[mcp]". If pip is not found, a warning is printed — install it manually:

pip install "ai-knot[mcp]"

Quickstart

import { KnowledgeBase } from 'ai-knot';

const kb = new KnowledgeBase({
  agentId: 'my-agent',
  storage: 'sqlite',
  dbPath: '/absolute/path/to/memory.db',
});

// Add a fact
await kb.add('User prefers TypeScript');

// Recall relevant facts for a query
const context = await kb.recall('what language does user prefer?');
console.log(context);
// -> "[semantic] User prefers TypeScript"

// Use context in your prompt
const response = await openai.chat.completions.create({
  model: 'gpt-4o',
  messages: [
    { role: 'system', content: `You are a helpful assistant.\n\n${context}` },
    { role: 'user', content: 'Write me a script' },
  ],
});

await kb.close();

API

new KnowledgeBase(options?)

const kb = new KnowledgeBase({
  agentId?: string,    // default: "default"
  storage?: 'yaml' | 'sqlite',  // default: "yaml"
  dataDir?: string,   // base dir for YAML/SQLite (use absolute path!)
  dbPath?: string,    // full path to SQLite file
  command?: string,   // path to ai-knot-mcp binary
});

Use absolute paths for dataDir and dbPath — the subprocess may run from a different working directory.

Methods

await kb.add(content, options?)   // → Fact
await kb.recall(query, options?)  // → string (formatted facts)
await kb.forget(factId)           // → void
await kb.listFacts()              // → Fact[]
await kb.stats()                  // → Stats
await kb.snapshot(name)           // → void
await kb.restore(name)            // → void
await kb.close()                  // → void (shuts down subprocess)

add options

{
  type?: 'semantic' | 'procedural' | 'episodic',  // default: "semantic"
  importance?: number,  // 0.0–1.0, default: 0.8
  tags?: string[],
}

recall options

{
  topK?: number,  // max facts to return, default: 5
}

Memory types

| Type | Use for | Example | |---|---|---| | semantic | Facts about the user/world | "User works at Acme Corp" | | procedural | How the user wants things done | "Always use TypeScript strict mode" | | episodic | Specific past events | "Deploy failed last Tuesday" |


Concurrent calls

All method calls are safe to run concurrently:

const [facts, stats] = await Promise.all([
  kb.listFacts(),
  kb.stats(),
]);

Snapshots

await kb.snapshot('before-refactor');
await kb.restore('before-refactor');

Requires SQLite or YAML storage backend.


Lifecycle

Always call kb.close() when done:

const kb = new KnowledgeBase({ agentId: 'bot' });
try {
  await kb.add('...');
  const ctx = await kb.recall('...');
} finally {
  await kb.close();
}

Environment variables

| Variable | Default | Description | |---|---|---| | AI_KNOT_AGENT_ID | default | Agent namespace | | AI_KNOT_STORAGE | yaml | yaml or sqlite | | AI_KNOT_DATA_DIR | .ai_knot | Base dir (use absolute path) | | AI_KNOT_DB_PATH | — | Full path to SQLite file |


License

MIT