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

@webneat/codewiki

v0.0.6

Published

Core library for parsing, analyzing, and documenting TypeScript codebases

Readme

@webneat/codewiki

Core library for parsing, analyzing, and documenting TypeScript codebases with dependency tracking and topological ordering.

Overview

@webneat/codewiki is a TypeScript codebase analysis engine that builds a comprehensive knowledge graph of your code. It extracts symbols, files, directories, and dependencies, then provides topological ordering to enable AI tools to generate contextual documentation with maximum context for each entity.

Features

  • 🔍 TypeScript AST Parsing - Extract symbols, imports, exports, and file structure
  • 📊 Dependency Analysis - Build complete dependency graphs between files, symbols, and external packages
  • 🗄️ SQLite Storage - Fast, portable database with Drizzle ORM for codebase metadata
  • 📝 Description Management - Store and manage contextual documentation with smart ordering
  • Incremental Updates - Git-based change detection for fast re-indexing
  • 🎯 Topological Ordering - Intelligent entity ordering to enable optimal AI context
  • 🔗 Relationship Tracking - Complete import/export relationships and internal symbol links

Installation

pnpm add @webneat/codewiki

Quick Start

import { create, load } from '@webneat/codewiki'

// Create a new wiki instance
const wiki = await create({
  db_path: './codewiki.db',
  project_path: './my-typescript-project',
  description: 'My awesome TypeScript project'
})

// Or load an existing wiki database
const wiki = await load('./codewiki.db')

// Update the wiki with latest changes
await wiki.update()

// Get counts of entities in different states
const counts = wiki.counts()
console.log(`Ready: ${counts.symbols.ready} symbols, ${counts.files.ready} files`)

// Get next entities to describe (in topological order)
const toDescribe = wiki.to_describe(10)
if (toDescribe.type === 'symbols') {
  console.log(`Next symbols to describe: ${toDescribe.items.map(s => s.name).join(', ')}`)
}

Core API

CodeWiki Interface

The main interface provides access to all entity types:

interface CodeWiki {
  readonly config: Config
  update(): Promise<void>                    // Re-index the project
  counts(): WikiCounts                       // Get entity counts by state
  to_describe(limit: number): EntitiesToDescribe // Get next entities for AI description
  
  files: FilesWiki           // File operations
  symbols: SymbolsWiki       // Symbol/function/class operations  
  directories: DirectoriesWiki // Directory operations
  dependencies: DependenciesWiki // External dependency operations
}

Entity Operations

Each entity type provides a consistent API:

// Search and retrieve
const files = wiki.files.search({ where: { state: 'ready' }, limit: 10 })
const file = wiki.files.get(fileId)

// Set AI-generated descriptions
wiki.files.set_description(fileId, 'This file contains utility functions...')

// Query relationships
const importedFiles = wiki.files.imported_by_file(fileId)
const usingSymbols = wiki.symbols.using_dependency(dependencyId)

Entity Types

Files

  • States: to_scanto_describeready
  • Tracks: File metadata, imports, exports, symbols
  • Relationships: Import relationships with other files and external dependencies

Symbols

  • States: to_linkto_describeready
  • Tracks: Functions, classes, variables, types
  • Relationships: Internal symbol references and external dependency usage

Directories

  • States: to_describeready
  • Tracks: Directory structure and contents
  • Relationships: Parent-child relationships and contained files

External Dependencies

  • States: to_describeready
  • Tracks: npm packages, built-in modules
  • Relationships: Usage by files and symbols

Topological Description Order

The to_describe() method returns entities in an intelligent order that maximizes AI context:

  1. External Dependencies (no dependencies)
    • Built-in packages first, then by usage count
  2. Symbols (depend on other symbols and dependencies)
    • Fewest missing dependencies first, then by complexity
  3. Files (contain symbols and have imports)
    • Fewest missing descriptions first, then by file size
  4. Directories (contain files and subdirectories)
    • Fewest missing content first, then by total size

This ensures that when describing an entity, all its dependencies are already described.

CLI Usage

The package includes a comprehensive CLI:

# Initialize and index a project
codewiki update

# Show current status
codewiki status

# Search entities
codewiki files search --where.state=ready
codewiki symbols search --where.name="myFunction"

# Set descriptions
codewiki symbols set-description 123 "This function does X..."

# Query relationships
codewiki files imported-by-file 456
codewiki dependencies used-by-file 456

Database Schema

Uses SQLite with Drizzle ORM. Key tables:

  • files - File metadata and state
  • symbols - Function/class/variable definitions
  • directories - Directory structure
  • external_dependencies - npm packages and built-ins
  • imports - File-to-file import relationships
  • symbol_*_links - Symbol dependency relationships

Configuration

type Config = {
  db_path: string              // SQLite database file path
  project_path: string         // Root directory of TypeScript project
  description?: string         // Optional project description
  package_json_path?: string   // Optional package.json location
  node_modules_paths?: string[] // Optional node_modules directories
}

Development

# Install dependencies
pnpm install

# Build the library
pnpm build

# Run tests
pnpm test

# Type checking
pnpm typecheck

# Database operations
pnpm db:generate  # Generate migrations
pnpm db:push      # Push schema changes
pnpm db:studio    # Open Drizzle Studio

Architecture

This is the core library that powers:

  • codewiki-cli - Command-line interface and MCP server
  • codewiki-vscode - VSCode extension (planned)

The library is designed to be:

  • Incremental - Only processes changed files
  • Performant - Uses SQLite and efficient AST parsing
  • Extensible - Clean separation between parsing, storage, and API layers
  • Type-safe - Full TypeScript support throughout

License

MIT © Amine Ben hammou