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

@binclusive/code-graph

v0.0.1

Published

Agent-native TypeScript code-graph + smell CLI: parse a folder with ts-morph, measure every function, flag smells, and rank refactor targets as deterministic JSON.

Readme

@binclusive/code-graph

Agent-native TypeScript code-graph + smell tool. Point it at a folder; it parses every .ts/.tsx (via ts-morph), measures each function (loc, complexity, nesting depth, comment lines), groups them into modules and directories, flags smells against the thresholds in schema.ts, and ranks refactor targets. Output is deterministic JSON (sorted object keys, sorted arrays — same input, same bytes) so an agent reads a graph instead of re-reading files.

The default run is cheap (no tsconfig, syntactic getters only — fast). Call edges (calls/calledBy/importedBy/callChainDepth + their smells) are an opt-in pass triggered by --edges, --deep, or --blast.

Invocation

The canonical invocation is pnpm code-graph <path> [flags] run from the repo root, where <path> is relative to the repo root (e.g. pnpm code-graph services/audit-agents --plan). Absolute paths also work. The root code-graph script runs the tool from source via tsx with cwd = repo root, so root-relative paths resolve — no build step needed. The tables below write code-graph X for brevity; read that as pnpm code-graph X from the repo root.

Usage contract

When sent to refactor folder X, the first moves are Bash calls, not Reads:

| Goal | Call | |---|---| | Orient — health + worst offenders (first call) | code-graph X | | Ranked refactor targets, re-rankable | code-graph X --plan [--by rot\|impact\|complexity\|size] | | Indented file → function tree with inline smell markers | code-graph X --tree | | One file's functions + line ranges | code-graph X --file <f> | | Blast radius before changing a signature (intra-package) | code-graph X --blast <id> | | Cross-package blast radius (before changing a shared export) | code-graph X --blast <id> --deep | | Full graph (rarely — large) | code-graph X --graph | | CI gate (fail on smells) | code-graph X --ci [--fail-on high\|warn] [--max <n>] |

--blast requires an unambiguous target — pass the id (file:name), not a bare name. In default (package) scope, blast output is flagged incomplete for cross-package callers; re-run with --deep.

Flags

| Flag | Behavior | |---|---| | (none) | Summary JSON: health band, counts, worst file/function, top targets, parse failures | | --graph | Full Graph JSON (the large dump, on demand) | | --plan [--by rot\|impact\|complexity\|size] | Ranked PlanRow[] (human table, top 20). --json → full PlanRow[] | | --smells | All smells grouped by kind (human). --jsonSmell[] | | --tree | Indented file → function L12-48 loc=36 cx=8 nest=3 [smell markers]. Color when a TTY, plain when piped. --json falls back to the full graph | | --file <f> | One module + its functions. Warns if <f> is in parseFailures | | --blast <id> | Direct + transitive callers of <id>. Ambiguous bare name exits non-zero. package scope flags omitted cross-package callers | | --edges | Opt-in edge pass at package scope: adds edge data + the high-fan-in / deep-call-chain smells | | --deep | Edge pass over the whole monorepo; implies --edges at deep scope | | --ci [--fail-on high\|warn] [--max <n>] | Gate: exit non-zero per policy. --fail-on high (default) fails on any high-severity smell; --fail-on warn fails on any smell; --max <n> fails if total smell count exceeds n. Cheap by default; add --edges/--deep to gate on edge smells too | | --thresholds <file> | JSON file of partial threshold overrides, parsed through ThresholdsSchema.partial() and merged over the defaults. A typo'd key or wrong-typed value exits cleanly (exit code 2, one-line message) | | --pretty | Pretty-print JSON output | | --json | Force JSON output on a view command |

(No --out — redirect stdout.)

Self-gate

@binclusive/code-graph gates itself. src/selfcheck.test.ts runs the tool's cheap-pass analysis on its own src/ against selfcheck.thresholds.json and fails the build if any non-test function trips a structural smell — so the tool meets the standard it enforces. The gate runs at the defaults (selfcheck.thresholds.json is {}, no relaxed threshold); test files are excluded because their fixtures are intentionally gnarly. The failure message names the offending kind, target, and value vs threshold, so a regression is obvious without re-running the CLI.

Read SPEC.md for the contract.