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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@morphllm/morphsdk

v0.2.62

Published

TypeScript SDK and CLI for Morph Fast Apply integration

Downloads

10,592

Readme

Morph SDK

Production-ready tools for AI coding agents: Repo Storage with automatic code indexing, semantic search, and Fast Apply (10,500 tokens/s).

npm version

Install

npm install @morphllm/morphsdk

Get your API key: morphllm.com/dashboard/api-keys

export MORPH_API_KEY="sk-your-key-here"

Features

  • 🔍 Semantic Search - State of the Art Code Search (AST aware chunking, morph-v4-embedding + morph-v4-rerank)
  • 📦 Repo Storage - Agent native git with automatic code indexing, agent metadata, and chat history
  • ⚡ Fast Apply - 98% 1st pass accuracy, AI-powered code editing at 10,500 tokens/s
  • 🤖 Agent Tools - Ready-to-use tools for Anthropic, OpenAI, and Vercel AI SDK

Quick Start

Repo Storage + Semantic Search

import { MorphClient } from '@morphllm/morphsdk';

const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });

// Initialize repo
await morph.git.init({ repoId: 'my-project', dir: './my-project' });

// Commit with agent metadata
await morph.git.add({ dir: './my-project', filepath: '.' });
await morph.git.commit({
  dir: './my-project',
  message: 'Add authentication'
});

// Push (triggers automatic code embedding, 3-8s)
await morph.git.push({ dir: './my-project' });

// Search your code with natural language
const results = await morph.codebaseSearch.search({
  query: "Where is the OAuth login implemented?",
  repoId: 'my-project',
  targetDirectories: [] // or ['src/auth'] to narrow search
});

console.log(results.results[0].content);

Fast Apply

import { MorphClient } from '@morphllm/morphsdk';

const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });

// AI-powered file editing
await morph.fastApply.execute({
  target_filepath: 'src/app.ts',
  instructions: 'Add error handling',
  code_edit: 'try { ... } catch (e) { ... }'
});

Repo Storage

Git built for AI agents with automatic code indexing and semantic search.

Git Operations

// Initialize
await morph.git.init({ repoId: 'my-project', dir: './my-project' });

// Clone
await morph.git.clone({ repoId: 'my-project', dir: './local-copy' });

// Stage and commit
await morph.git.add({ dir: './my-project', filepath: '.' });
await morph.git.commit({ 
  dir: './my-project', 
  message: 'Add feature'
});

// Push (triggers code embedding in background)
await morph.git.push({ dir: './my-project' });

// Status and history
const files = await morph.git.statusMatrix({ dir: './my-project' });
const commits = await morph.git.log({ dir: './my-project', depth: 10 });

// Branch operations
await morph.git.branch({ dir: './my-project', name: 'feature' });
const branches = await morph.git.listBranches({ dir: './my-project' });
await morph.git.checkout({ dir: './my-project', ref: 'main' });

Agent Metadata

Store chat history and browser recordings with commits:

// Commit with metadata
const sha = await morph.git.commit({
  dir: './my-project',
  message: 'Implement user auth',
  chatHistory: [
    { role: 'user', content: 'Add OAuth' },
    { role: 'assistant', content: 'Adding Google OAuth' }
  ],
  recordingId: 'rec_abc123'
});

// Retrieve metadata later
const metadata = await morph.git.getCommitMetadata({
  dir: './my-project',
  commitSha: sha
});

console.log(metadata?.chatHistory);
console.log(metadata?.recordingId);

State of the Art Code Semantic Search

When you push, Morph automatically embeds your code for semantic search. Each commit is indexed separately:

// Search latest code on 'main'
await morph.codebaseSearch.search({ 
  query: "auth logic", 
  repoId: 'my-project' 
});

// Advanced: Search specific branch
await morph.codebaseSearch.search({ 
  query: "auth logic", 
  repoId: 'my-project',
  branch: 'develop' 
});

// Advanced: Search exact commit
await morph.codebaseSearch.search({ 
  query: "auth logic", 
  repoId: 'my-project',
  commitHash: 'abc123...' 
});

Semantic Search

Two-stage retrieval: embedding similarity (morph-v4-embedding) + reranking (morph-v4-rerank).

As Agent Tool

import { createCodebaseSearchTool } from '@morphllm/morphsdk/tools/anthropic';
import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic();
const tool = createCodebaseSearchTool({ repoId: 'my-project' });

const response = await client.messages.create({
  model: "claude-sonnet-4-5-20250929",
  tools: [tool],
  messages: [{ role: "user", content: "Find authentication code" }]
});

Direct Search

const results = await morph.codebaseSearch.search({
  query: "How does authentication work?",
  repoId: 'my-project',
  targetDirectories: ["src/auth"], // or [] for all
  limit: 10
});

results.results.forEach(r => {
  console.log(`${r.filepath} (${(r.rerankScore * 100).toFixed(1)}% relevant)`);
  console.log(r.content);
});

How It Works

  1. Embedding Search: Query embedded with morph-v4-embedding, vector search retrieves top 50 candidates (~50ms)
  2. Reranking: Candidates scored with morph-v4-rerank for precision (~150ms)
  3. Results: Top 10 most relevant code chunks (~1230ms total)

Fast Apply

AI-powered code editing at 10,500 tokens/s. See tools/fastapply/README.md for details.

Agent Tools

Ready-to-use tools for popular AI frameworks:

  • Anthropic SDK - @morphllm/morphsdk/tools/anthropic
  • OpenAI SDK - @morphllm/morphsdk/tools/openai
  • Vercel AI SDK - @morphllm/morphsdk/tools/vercel

Available tools:

  • createCodebaseSearchTool - Semantic code search
  • createFastApplyTool - AI-powered code editing
  • createBrowserTool - Browser automation
  • createWarpGrepTool - Fast grep with AI parsing

Documentation

Full docs: docs.morphllm.com

Key Pages: