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

agentic-compaction

v0.0.7

Published

Walk a project directory and output a compact structural skeleton of the entire codebase

Readme

agentic-compaction

Walks a project directory, parses JS/TS/Python files, and outputs a compact structural skeleton of the entire codebase. Designed for feeding project context into LLM prompts with minimal token usage.

Typical compaction rate: ~95% token reduction.

Quick Start

npx agentic-compaction /path/to/project

Install

npm install -g agentic-compaction

CLI Usage

agentic-compaction [path] [options]

Options:

| Flag | Description | |------|-------------| | --json | Save output as JSON (includes stats) | | --help, -h | Show help |

If no path is given, it defaults to the current directory.

Output is saved to the target directory as compacted_<project>_<date>.md.

Example:

$ npx agentic-compaction ~/projects/my-app

Saved to /home/user/projects/my-app/compacted_my-app_2026-02-12_15-30-00.md

  Files:            96
  Project tokens:   106.9K
  Compacted tokens: 5.9K
  Compaction rate:  94.4%

Library Usage

import { compactProject, compactFile } from 'agentic-compaction';

// Compact an entire directory
const { output, stats } = compactProject('/path/to/project');
console.log(output);
console.log(stats); // { files, rawTokens, compactedTokens }

// Compact a single file
const { skeleton, formatted } = compactFile('app.tsx', sourceCode);

Output Format

Each file is rendered as a markdown heading followed by its structural skeleton:

## src/components/App.jsx
imports: 3 ext, ./hooks/useAuth, ./api/client
exports: App*
components: App:12
fn: handleSubmit:24, validate:40
hooks: useState(2), useEffect([user]):18, useAuth

The skeleton captures:

  • Imports (deduplicated local paths shown, externals counted)
  • Exports (default marked with *)
  • Components (top-level PascalCase functions, HOC-wrapped)
  • Functions (top-level only, with line numbers)
  • Hooks (only from top-level components: counts, useEffect deps, custom hooks)
  • Constants (top-level only)
  • Classes, interfaces, types (TS)
  • Python: imports, classes (with bases/decorators), functions, constants

Supported Languages

| Language | Parser | Extensions | |----------|--------|------------| | JavaScript | @babel/parser (top-level only) | .js, .jsx, .mjs, .cjs | | TypeScript | @babel/parser (top-level only) | .ts, .tsx, .mts, .cts | | Python | Regex-based (top-level only, zero deps) | .py |

Skipped Directories

node_modules, dist, .git, target, build, .next, .turbo, out, coverage, .cache, __pycache__, .venv, venv, .idea, .vscode, and any dotfile directories.

Project Structure

src/
  cli.js            # CLI entry point
  index.js          # Library API: compactProject, compactFile
  walker.js         # Recursive directory walker with filtering
  formatter.js      # Output formatting + token estimation
  parsers/
    babel.js        # JS/TS parsing via Babel AST
    python.js       # Python parsing via regex (top-level only)

Tests

npm test

License

MIT