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

@justin26l/codegraph

v0.1.0

Published

Multi-language code relation graph navigator for humans and AI agents

Downloads

83

Readme

code-relation-graph

A CLI tool that parses your source code and builds an interactive graph of relations between files, functions, and classes. Helps humans and AI agents understand code structure — what calls what, what imports what, and where things live.

Quick start

# Install globally (from this repo)
npm install -g .
# or run directly:
node dist/cli.js --help

# Parse a TypeScript project
codegraph parse ./my-project --languages ts

# Generate interactive HTML visualization
codegraph html ./my-project -o graph.html
# Open graph.html in any browser

# Export graph as JSON (for AI agents / programmatic use)
codegraph export ./my-project -o graph.json

# Show graph statistics
codegraph stats ./my-project

Commands

| Command | Description | |---------|-------------| | parse | Parse source files and build graph database | | html | Generate interactive HTML visualization | | export | Export graph as JSON | | stats | Show node/edge counts by type |

Options

| Flag | Default | Description | |------|---------|-------------| | --languages | ts | Comma-separated languages (ts, py, go) | | --exclude | **/*.test.*,node_modules/** | Exclude patterns | | --include | — | Restrict parsing to specific paths | | -o, --output | — | Output file path |

What it does

  • Parses TypeScript/JavaScript (Python/Go planned) using tree-sitter
  • Builds a graph with: files, directories, classes, functions/methods
  • Resolves cross-file calls — when auth.login() is called in index.ts, the edge points to the actual login method in auth.ts
  • Tracks file-to-file imports
  • Generates a self-contained HTML file (no server, no build step) with an interactive vis-network visualization

HTML visualization features

  • Hierarchical layout (default) — directories at top, files below, functions at bottom
  • Force-directed layout — switch via dropdown
  • Search — filter nodes by name in real-time
  • Type filter — show/hide directories, files, classes, functions
  • Edge toggles — show/hide CONTAINS, CALLS, IMPORTS edges
  • Focus mode — click a node to dim everything except its neighbors; double-click to restore
  • Click any node to see its file path, line range, and type

Language support

| Language | Status | |----------|--------| | TypeScript / JavaScript | ✅ Working | | Python | ⏳ Grammar installed, adapter not yet written | | Go | ⏳ Grammar installed, adapter not yet written |

Example

# Parse a project
codegraph parse ~/projects/my-app --languages ts --include "src/**"

# Open the visual graph
codegraph html ~/projects/my-app
open graph.html

# Feed the JSON to an AI agent
codegraph export ~/projects/my-app | pbcopy