context-squeezer-cli 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,72 +1,123 @@
1
- # 🚀 Context-Squeezer
1
+ # 🚀 Context-Squeezer-CLI
2
2
 
3
3
  ![CI](https://github.com/ErhanNamal/context-squeezer/actions/workflows/ci.yml/badge.svg)
4
- ![npm](https://img.shields.io/badge/npm-friendly-brightgreen)
4
+ [![npm version](https://img.shields.io/npm/v/context-squeezer-cli.svg?style=flat-flat)](https://www.npmjs.com/package/context-squeezer-cli)
5
+ ![npm downloads](https://img.shields.io/npm/dm/context-squeezer-cli?color=blue)
6
+ ![license](https://img.shields.io/npm/l/context-squeezer-cli?color=brightgreen)
5
7
 
6
- Lightweight CLI that packs a repository into a single, LLM-optimized context file. Ideal for feeding projects to ChatGPT, Claude, or local LLMs without wasting tokens on irrelevant files.
8
+ Lightweight and blazing fast TypeScript CLI that packs an entire repository into a single, LLM-optimized context file. Ideal for feeding your codebases directly into ChatGPT, Claude, or local LLMs without wasting precious tokens on junk files.
7
9
 
8
10
  ---
9
11
 
10
12
  ## 🔥 Features
11
13
 
12
- - **Smart Code Squeezing:** Produces a structured, human- and LLM-friendly summary of your codebase.
13
- - **Automatic Ignore Detection:** Skips common heavy folders and files (`node_modules`, `.git`, `dist`, lockfiles, etc.).
14
- - **Live Stats & Token Estimation:** Shows total files, lines, characters and an estimated LLM token count.
15
- - **Custom Output:** Change the output filename or destination with a CLI flag.
14
+ - **⚡ Blazing Fast Squeezing:** Traverses your repository and compiles a structured, human- and LLM-friendly master text file in milliseconds.
15
+ - **🛡️ Default & Custom Ignores:** Automatically skips heavy or compiled asset folders (`node_modules`, `.git`, `dist`, lockfiles) and respects your custom `.aiignore` rules.
16
+ - **🔒 Security & Privacy First:** Built-in binary file detection prevents image/PDF leakage, and an automated data masker redacts sensitive strings like API keys, secrets, or passwords before outputting.
17
+ - **📊 Token Load Estimation:** Instantly calculates total processed files, lines, characters, and provides a live, estimated LLM token count.
16
18
 
17
19
  ---
18
20
 
19
- ## 🛠️ Installation
21
+ ## 🛠️ Quick Start (No Installation Required)
20
22
 
21
- Clone and install dependencies:
23
+ You don't even need to clone or install it locally to try it out. Just navigate to your target project directory in your terminal and fire it up using `npx`:
22
24
 
23
25
  ```bash
24
- git clone https://github.com/ErhanNamal/context-squeezer.git
25
- cd context-squeezer
26
- npm install
26
+ npx context-squeezer-cli
27
27
  ```
28
28
 
29
- ## 🚀 Usage
29
+ This will immediately analyze your current directory and generate a clean `ai_context.txt` file in your root folder.
30
30
 
31
- Squeeze the current project and write the default `ai_context.txt`:
31
+ ---
32
32
 
33
- ```bash
34
- npm start
35
- ```
33
+ ## ⚙️ Advanced Usage & Options
36
34
 
37
- Specify a custom output path:
35
+ You can easily customize the output filename or paths using standard CLI flags:
38
36
 
39
37
  ```bash
40
- npm start -- --output my_project_summary.txt
38
+ # Save to a custom file name
39
+ npx context-squeezer-cli --output codebase_summary.txt
40
+
41
+ # Short flag version
42
+ npx context-squeezer-cli -o summary.txt
41
43
  ```
42
44
 
43
- ## 🖥️ Terminal Dashboard (example)
45
+ ---
46
+
47
+ ## 🚫 Custom Ignore Rules (.aiignore)
48
+
49
+ Create an `.aiignore` file in the root of your project to skip specific extensions or internal directories, just like a `.gitignore`:
44
50
 
45
- When run, the CLI prints a compact analytics dashboard similar to the example below:
51
+ ```plaintext
52
+ # .aiignore template
53
+ # Ignore entire custom scripts folder
54
+ scripts
46
55
 
56
+ # Ignore specific output logs
57
+ test_output.txt
58
+
59
+ # Ignore all JSON files
60
+ *.json
47
61
  ```
62
+
63
+ ---
64
+
65
+ ## 🖥️ Terminal Dashboard Preview
66
+
67
+ When run successfully, the CLI renders a compact, high-readability analytics report directly in your terminal:
68
+
69
+ ```plaintext
48
70
  =============================================
49
71
  🚀 CONTEXT-SQUEEZER - AI Context Prepared
50
72
  =============================================
51
73
 
52
- 🔍 Analyzing directory: D:\Koufc\Yazılım Çalışmaları\Karışık\context-squeezer
74
+ 🔍 Analyzing directory: /home/user/projects/my-awesome-app
53
75
 
54
76
  📊 PROJECT ANALYTICS REPORT
55
77
  ---------------------------------------------
56
- 📂 Total Files Compressed : 5
57
- 📝 Total Lines of Code : 155
58
- 🔤 Total Character Count : 4940
59
- 🪙 Estimated LLM Token Load: ~1235 tokens
78
+ 📂 Total Files Compressed : 12
79
+ 📝 Total Lines of Code : 1,420
80
+ 🔤 Total Character Count : 45,280
81
+ 🪙 Estimated LLM Token Load: ~11,320 tokens
60
82
  ---------------------------------------------
61
83
 
62
84
  ✅ Success! Your LLM context file is ready:
63
- 👉 D:\Koufc\Yazılım Çalışmaları\Karışık\context-squeezer\ai_context.txt
85
+ 👉 /home/user/projects/my-awesome-app/ai_context.txt
64
86
  ```
65
87
 
66
- ## 🤝 Contributing
88
+ ---
89
+
90
+ ## 🛠️ Local Development & Contribution
91
+
92
+ If you want to clone the repo, add new features, or tweak the scanner locally:
93
+
94
+ ### Clone the repository:
67
95
 
68
- Contributions are welcome — open issues or pull requests for improvements. Add examples, edge-case handling, or CI workflows to help others use the tool.
96
+ ```bash
97
+ git clone https://github.com/ErhanNamal/context-squeezer.git
98
+ cd context-squeezer
99
+ ```
100
+
101
+ ### Install dependencies:
102
+
103
+ ```bash
104
+ npm install
105
+ ```
106
+
107
+ ### Run the CLI in development mode:
108
+
109
+ ```bash
110
+ npm start
111
+ ```
112
+
113
+ ### Build the production files:
114
+
115
+ ```bash
116
+ npm run build
117
+ ```
118
+
119
+ ---
69
120
 
70
121
  ## 📝 License
71
122
 
72
- Distributed under the MIT License. See LICENSE for details.
123
+ Distributed under the MIT License. See [LICENSE](LICENSE) for details.
package/dist/ignorer.js CHANGED
@@ -10,7 +10,6 @@ const DEFAULT_IGNORES = [
10
10
  'build',
11
11
  '.DS_Store'
12
12
  ];
13
- // Kuralları çalışma zamanında hafızada tutacak önbellek mekanizması
14
13
  let cachedCustomRules = null;
15
14
  /**
16
15
  * Projenin kök dizinindeki .aiignore dosyasını sadece bir kez okuyarak belleğe alır.
@@ -43,25 +42,20 @@ function loadCustomIgnoreRules(projectRoot) {
43
42
  * @param projectRoot Projenin ana çalışma dizini
44
43
  */
45
44
  export function shouldIgnore(filePath, projectRoot) {
46
- // Windows'taki \ işaretlerini / işaretine çevirerek yolları normalize ediyoruz
47
45
  const relativePath = path.relative(projectRoot, filePath).replace(/\\/g, '/');
48
46
  const parts = relativePath.split('/');
49
- // 1. Çıktı ve test dosyalarının kendi kendini taramasını engeller
50
47
  const file = path.basename(filePath);
51
48
  if (file.endsWith('.txt') && (file === 'ai_context.txt' || file === 'kodlarim.txt' || file === 'test_output.txt')) {
52
49
  return true;
53
50
  }
54
- // 2. Varsayılan global engelleme listesi kontrolü
55
51
  if (parts.some(part => DEFAULT_IGNORES.includes(part))) {
56
52
  return true;
57
53
  }
58
- // 3. Kullanıcı tanımlı .aiignore kurallarının kontrolü
59
54
  const customRules = loadCustomIgnoreRules(projectRoot);
60
55
  for (const rule of customRules) {
61
- // .aiignore içindeki olası Windows yollarını da normalize et
62
56
  const normalizedRule = rule.replace(/\\/g, '/');
63
57
  if (normalizedRule.startsWith('*.')) {
64
- const ext = normalizedRule.slice(1); // Örn: .json uzantısını yakalar
58
+ const ext = normalizedRule.slice(1);
65
59
  if (filePath.endsWith(ext))
66
60
  return true;
67
61
  }
package/dist/packager.js CHANGED
@@ -1,12 +1,7 @@
1
1
  import * as fs from 'fs';
2
2
  import * as path from 'path';
3
3
  import { shouldIgnore } from './ignorer.js';
4
- // Güvenli işleme için maksimum dosya boyutu sınırı (Örn: 500 KB)
5
4
  const MAX_FILE_SIZE_BYTES = 500 * 1024;
6
- /**
7
- * Bir dosyanın ikili (binary) olup olmadığını ilk byte bloklarını tarayarak kontrol eder.
8
- * @param filePath Denetlenecek dosyanın tam yolu
9
- */
10
5
  function isBinaryFile(filePath) {
11
6
  const buffer = Buffer.alloc(512);
12
7
  let fd = null;
@@ -14,7 +9,6 @@ function isBinaryFile(filePath) {
14
9
  fd = fs.openSync(filePath, 'r');
15
10
  const bytesRead = fs.readSync(fd, buffer, 0, 512, 0);
16
11
  for (let i = 0; i < bytesRead; i++) {
17
- // Null karakteri (\0) kontrolü ikili dosyaları tespit etmek için en güvenli yöntemdir
18
12
  if (buffer[i] === 0) {
19
13
  return true;
20
14
  }
@@ -22,7 +16,7 @@ function isBinaryFile(filePath) {
22
16
  return false;
23
17
  }
24
18
  catch (err) {
25
- return true; // Okuma hatası durumunda güvenli tarafta kalmak için binary kabul edilir
19
+ return true;
26
20
  }
27
21
  finally {
28
22
  if (fd !== null) {
@@ -30,9 +24,6 @@ function isBinaryFile(filePath) {
30
24
  }
31
25
  }
32
26
  }
33
- /**
34
- * Kod içindeki hassas şifre, token ve API anahtarlarını sansürler
35
- */
36
27
  function maskSensitiveData(content) {
37
28
  const sensitivePatterns = [
38
29
  /(secret[-_]?key|api[-_]?key|password|passwd|auth[-_]?token|client[-_]?secret)\s*[:=]\s*['"`][^'"`]{4,200}['"`]/gi,
@@ -65,8 +56,6 @@ export function packProject(dirPath) {
65
56
  for (const file of files) {
66
57
  const fullPath = path.join(currentDir, file);
67
58
  const stat = fs.statSync(fullPath);
68
- // Modüler kontrol: Dosya veya klasörün engellenip engellenmeyeceğini kontrol eder
69
- // (Çıktı .txt dosyaları da artık tamamen ignorer.ts içinde yakalanıyor)
70
59
  if (shouldIgnore(fullPath, dirPath)) {
71
60
  continue;
72
61
  }
@@ -75,12 +64,10 @@ export function packProject(dirPath) {
75
64
  }
76
65
  else if (stat.isFile()) {
77
66
  const relativePath = path.relative(dirPath, fullPath);
78
- // PERFORMANS & GÜVENLİK: Belirlenen boyuttan büyük dosyaları atlar
79
67
  if (stat.size > MAX_FILE_SIZE_BYTES) {
80
68
  console.warn(`⚠️ Skipped large file (over 500KB): ${relativePath}`);
81
69
  continue;
82
70
  }
83
- // GÜVENLİK: İkili (Resim, PDF, Derlenmiş Dosya vb.) içerikleri filtreler
84
71
  if (isBinaryFile(fullPath)) {
85
72
  continue;
86
73
  }
@@ -95,7 +82,7 @@ export function packProject(dirPath) {
95
82
  combinedContent += `\n--- END OF FILE: ${relativePath} ---\n`;
96
83
  }
97
84
  catch (e) {
98
- // Okunamayan dosyalarda çökmesini önlemek için es geçiyoruz
85
+ // Hata durumunda es geç
99
86
  }
100
87
  }
101
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-squeezer-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Lightweight CLI that packs a repository into a single, LLM-optimized context file.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",