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 🙏

© 2025 – Pkg Stats / Ryan Hefner

codesnap-analyzer

v1.0.6

Published

Create comprehensive snapshots of your codebase with token counting for LLMs

Downloads

344

Readme

CodeSnap Analyzer Node.js

https://github.com/phamhung075/codesnap-analyzer

A tool for creating comprehensive snapshots of your codebase with token counting for LLMs. result like GitIngest

Installation

npm install -g codesnap-analyzer

Usage

Command Line

# Analyze current directory
codesnap

# Analyze specific directory
codesnap ./my-project

# With options
codesnap . -o output.txt -i "*.ts" "*.tsx" -e "tests" "docs"

Example Output Command Line

PS D:\DaiHung\__labo\codesnap> codesnap . 
📸 Starting CodeSnap analysis...
📁 Project: codesnap-analyzer
📂 Directory: D:\DaiHung\__labo\codesnap
📝 Output will be saved to: D:\DaiHung\__labo\codesnap\codesnap\codesnap-analyzer.txt

🔍 Looking for .gitignore at: D:\DaiHung\__labo\codesnap\.gitignore
✅ Found .gitignore file

📋 Active ignore patterns:

   Default patterns:
   - node_modules
   - package-lock.json
   - yarn.lock
   - .npm
   - .git
   - .svn
   - .hg
   - dist
   - build
   - out
   - .idea
   - .vscode
   - .tmp
   - tmp
   - .DS_Store
   - Thumbs.db
   - *.jpg
   - *.jpeg
   - *.png
   - *.gif
   - *.ico
   - *.pdf
   - *.exe
   - *.dll
   - *.so
   - *.dylib
   - codesnap

   From .gitignore:
   - node_modules/
   - package-lock.json
   - yarn.lock
   - .npm/
   - dist/
   - build/
   - lib/
   - *.tsbuildinfo
   - coverage/
   - .nyc_output/
   - jest-report/
   - test-report/
   - logs/
   - *.log
   - npm-debug.log*
   - yarn-debug.log*
   - yarn-error.log*
   - pids
   - *.pid
   - *.seed
   - *.pid.lock
   - .idea/
   - .vscode/
   - *.swp
   - *.swo
   - .DS_Store
   - .env
   - .env.*
   - !.env.example
   - .temp/
   - .tmp/
   - .cache/
   - *.tsbuildinfo
   - .npm
   - .eslintcache
   - docs/_build/
   - docs/_static/
   - docs/_templates/
   - debug.log
   - debug.test.log
   - output/
   - codesnap/

📂 Starting directory analysis...
📁 Base directory: D:\DaiHung\__labo\codesnap

⚙️  Settings:
   Max file size: 10.00 MB
   Max total files: 10000
   Max total size: 500.00 MB

🔍 Scanning for files...
   ⏭️  Skipping directory: .git (matches ignore pattern)
   ⏭️  Skipping directory: codesnap (matches ignore pattern)
   ⏭️  Skipping directory: dist (matches ignore pattern)
   ⏭️  Skipping directory: node_modules (matches ignore pattern)
✨ Found 18 files total

📄 Processing files:
   ✅ Reading: .gitignore
   ✅ Reading: README.md
   ✅ Reading: eslint.config.mjs
   ✅ Reading: jestconfig.json
   ✅ Reading: package.json
   ✅ Reading: pnpm-lock.yaml
   ✅ Reading: src/__tests__/cli.test.ts
   ✅ Reading: src/cli.ts
   ✅ Reading: src/constants/analyze.ts
   ✅ Reading: src/constants/patterns.ts
   ✅ Reading: src/core/analyzer.ts
   ✅ Reading: src/index.ts
   ✅ Reading: src/services/codesnap.ts
   ✅ Reading: src/services/formatter.ts
   ✅ Reading: src/types/types.ts
   ✅ Reading: src/utils/file.ts
   ✅ Reading: src/utils/token-counter.ts
   ✅ Reading: tsconfig.json

✅ Analysis completed successfully!
📊 Summary:
Project Directory: AIanalist
Total Files Analyzed: 107
Total Size: 0.33 MB
Date: 2025-01-01T17:49:26.916Z

Token counts and costs by model:
   GPT-3.5: 70.7K tokens → $0.1060
   GPT-4:   70.7K tokens → $2.1200
   Claude:  70.7K tokens → $1.0600
   LLaMA 2: 77.7K tokens → $0.1555

Example Output File

codesnap-analyzer.txt

Programmatic Usage

import { analyze } from 'codesnap-analyzer';

async function analyzeProject() {
  const result = await analyze('./my-project', {
    output: 'analysis.txt',
    includePatterns: ['*.ts', '*.tsx'],
    excludePatterns: ['tests', 'docs']
  });

  console.log(result.summary);
  console.log(result.tokenCounts);
}

Features

  • Comprehensive codebase analysis
  • Token counting for multiple LLM models (GPT-3.5, GPT-4, Claude, LLaMA 2)
  • Respect .gitignore patterns
  • Customizable include/exclude patterns
  • Binary file detection
  • Size limits handling
  • Tree structure visualization

Options

  • `output`: Output file path
  • `excludePatterns`: Additional patterns to exclude
  • `includePatterns`: Patterns to include

Token Counting

Provides token counts for:

  • GPT-3.5
  • GPT-4
  • Claude
  • LLaMA 2

License

MIT