1.0.8 ⢠Published 4 months ago
codesnap-analyzer v1.0.8
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
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