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

energy-state-analyzer

v0.7.0

Published

Visualize code energy states in real-time (Python, F#, TypeScript, Kotlin)

Readme

Energy State Analyzer

Visualizes "energy states" in Python, F#, and TypeScript code as you edit: parts of a file that are complex, deeply nested, or otherwise harder to understand and maintain get highlighted with colored gutter icons, inline decorations, and entries in the Problems panel.

Features

Real-time analysis of the active Python, F#, or TypeScript file, re-run on every edit and on editor focus change, via these detectors (see docs/detectors for full detail on each):

Violations are shown three ways:

  • A colored background + gutter lightning-bolt icon on the affected lines (orange = high severity, gold = medium, green = low; colors are configurable, see Extension Settings).
  • A hover tooltip explaining the specific violation.
  • An entry in the Problems panel, sourced as "Energy State Analyzer".

For functions flagged as too complex (cyclomatic or cognitive), a progressive heatmap in the configured high-energy color (orange by default) is also painted across the function body: each contributing line (an if, for, and, etc.) is shaded from light to dark based on how much it drives up that function's complexity relative to its own worst line, so you can see exactly which branches to break apart first, instead of just knowing the function as a whole is complex.

Energy and Entropy

The name is a deliberate analogy to thermodynamics: a function's "energy" is its complexity, nesting, and parameter count, while its "entropy" is how many ways a reader can misunderstand it or a change can silently break it. See docs/energy-and-entropy.md for the full explanation of why cyclomatic and cognitive complexity are tracked as separate metrics rather than one score.

Command-Line Usage

The same detectors also run headlessly, without VS Code, useful for CI or for an AI coding agent that wants to check the complexity of code it just generated and keep refactoring until it's clean:

npx energy-state-analyzer path/to/file.py   # or .fs / .fsx / .ts

See docs/cli.md for scanning a whole repo, aggregated markdown/JSON/human reports, and diffing a PR against a base branch.

Requirements

The extension activates automatically when you open a Python, F#, or TypeScript file; it bundles its own grammars for parsing (via web-tree-sitter), so no external tools are required. F# files only get a fsharp language ID (and so trigger analysis) if you have an F# language extension installed (e.g. Ionide), VS Code otherwise treats .fs files as plain text.

Extension Settings

Detector thresholds are configurable under Settings → Energy State Analyzer. See each detector's doc (linked under Features above) for what a setting does; the keys and defaults are:

  • energyStateAnalyzer.cyclomaticComplexity.mediumThreshold / .highThreshold (10 / 15)
  • energyStateAnalyzer.cognitiveComplexity.mediumThreshold / .highThreshold (15 / 25)
  • energyStateAnalyzer.coherence.largeFunctionLines (20)
  • energyStateAnalyzer.coherence.maxLargeFunctions (5)
  • energyStateAnalyzer.coherence.singleDomainNameShare (0.7)
  • energyStateAnalyzer.matchOpportunity.minBranches (3)
  • energyStateAnalyzer.magicNumber.enabled (true)
  • energyStateAnalyzer.magicNumber.allowlist ([0, 1, -1, 2])
  • energyStateAnalyzer.magicString.enabled (true)
  • energyStateAnalyzer.magicString.minDuplicates (2)
  • energyStateAnalyzer.magicString.allowlist (["", "utf-8", "__main__"])
  • energyStateAnalyzer.colors.highEnergy / .mediumEnergy / .lowEnergy (#fb8500 / #ffb703 / #99dd99)
  • energyStateAnalyzer.colors.backgroundOpacity (0.1)

Changes take effect immediately on the active editor.

To exclude files/folders (e.g. test fixtures, generated code) from both the extension's live analysis and the CLI, add a .esaignore file to your workspace root — see docs/cli.md.

Commands

  • Energy State Analyzer: Analyze Energy State (energy-state-analyzer.analyze), manually re-run analysis on the active editor.

Known Issues

  • Nesting depth and parameter count thresholds are not yet configurable via VS Code settings, only cyclomatic complexity, cognitive complexity, the large-function coherence check, the match-opportunity branch count, and the magic-number/magic-string detectors are.
  • TypeScript arrow functions aren't analyzed by complexity/parameter-count/coherence (same limitation Python already has for lambda), only named function declarations and class methods are.
  • Several detectors have per-language gaps beyond the above, see the "Known limitations" section of the relevant detector doc.