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

ts-semantic-graph

v1.0.1

Published

Callers, callees, symbol references, and module dependencies for TypeScript projects, resolved through the TypeScript compiler instead of text matching. Comes as a lookup CLI, a query daemon, an MCP server, and an importable library.

Readme

ts-semantic-graph

Callers, callees, symbol references, and module dependencies for TypeScript projects, resolved through the TypeScript compiler instead of text matching. Comes as a lookup CLI, a query daemon, an MCP server, and an importable library.

Requires Node 22.12+ and a TypeScript project.

Install

npm install --global ts-semantic-graph

Library

The same engine the CLI and MCP server use is importable:

import { CodeGraph } from "ts-semantic-graph";

const graph = await CodeGraph.load({
  repositoryRoot: "/path/to/repo",
  tsconfigPath: "/path/to/repo/tsconfig.json",
  backend: "ts7",
});
try {
  const result = await graph.lookup({ filePath: "src/target.ts", functionName: "Primary" });
  // result: GraphResult — status, target, relations with evidence, summary
} finally {
  await graph.dispose();
}

CodeGraph.load resolves paths, applies one validation policy, and picks the backend, so callers pass raw options and nothing else. Concurrent calls are serialized internally; refreshes never interleave with in-flight lookups.

Lookup CLI

# callers and callees, compact text (default)
ts-semantic-graph src/target.ts Primary --repo /path/to/repo

# full graph as JSON, plus references and module queries
ts-semantic-graph src/target.ts Primary --output json --repo /path/to/repo
ts-semantic-graph references src/symbols.ts ExampleInterface --repo /path/to/repo
ts-semantic-graph module src/target.ts --output detailed --repo /path/to/repo

Every query returns a versioned GraphResult: a status (ok, not-found, ambiguous), the target node, directed relations with source evidence, and a summary. --output json prints it unfiltered, which is what scripts and IDE integrations should consume. not-found and ambiguous are normal results, not errors. Pass --line when the same name is declared more than once in a file.

Text output is low-noise by default: known builtin and framework calls are hidden unless --include-builtins, and each section is capped at 12 items unless --max-items says otherwise. detailed adds per-relation evidence.

Daemon

A cold query starts a fresh tsserver each time. For repeated queries against a large project, keep one alive:

ts-semantic-graph serve start \
  --repo /path/to/repo \
  --tsconfig /path/to/repo/tsconfig.json
# { "daemonId": "482731", ... }

ts-semantic-graph serve lookup 482731 src/target.ts Primary
ts-semantic-graph serve references 482731 src/symbols.ts ExampleInterface
ts-semantic-graph serve module 482731 src/target.ts
ts-semantic-graph serve status 482731  # omit the ID to list all daemons
ts-semantic-graph serve stop 482731

Query and stop commands take only the ID; project options belong to serve start and are rejected elsewhere. Relative paths resolve from the daemon's repo root. IDs are ephemeral: if a daemon stops or crashes, start a new one.

MCP server

ts-semantic-graph-mcp \
  --repo /path/to/repo \
  --tsconfig /path/to/repo/tsconfig.json

Exposes lookup_function, find_symbol_references, and inspect_module_dependencies, with the same output, maxItems, and includeBuiltins options as the CLI.

Backends

The default backend is the project's own classic tsserver, discovered from its local TypeScript install. If that fails, pass the entrypoint:

ts-semantic-graph src/bar.ts baz --repo ~/Codes/foo \
  --tsserver ~/Codes/foo/node_modules/typescript/lib/tsserver.js

tsserver picks the nearest tsconfig.json per file, so --tsconfig is optional here; when given, it is only used to verify the expected project was picked up. The bundled TypeScript 7 backend does require it:

ts-semantic-graph src/bar.ts baz \
  --repo ~/Codes/foo --tsconfig ~/Codes/foo/tsconfig.json \
  --backend ts7

--max-old-space-size (default 8192 MB) and --request-timeout-ms tune the tsserver child. All backend options also apply to serve start and the MCP server. tsserver-only options are rejected under --backend ts7.

Limitations

The graph only records relations the compiler can vouch for directly, plus a few narrow patterns (useCallback/useMemo unwrapping, direct JSX renders). It does not infer through state updates, routing, Redux, or network calls.

Development

pnpm install --frozen-lockfile
pnpm test

TSSERVER_PATH=… pnpm test additionally runs the classic-tsserver integration tests against a specific tsserver.