@sidhxntt/token-squasher 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/README.md +129 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,129 @@
1
+ # token-squasher
2
+
3
+ Compress verbose system prompts into dense, token-efficient instructions without losing logic.
4
+
5
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org/)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+ [![npm version](https://img.shields.io/npm/v/@sidhxntt/token-squasher.svg)](https://www.npmjs.com/package/@sidhxntt/token-squasher)
8
+
9
+ ## Features
10
+
11
+ - **Token-efficient compression** - Reduces prompt length by removing filler while preserving all logic
12
+ - **Interactive REPL** - Multi-line prompt input with command support
13
+ - **Real-time statistics** - Token count reduction and compression percentage
14
+ - **Colored output** - Syntax highlighting for better readability
15
+ - **Claude Sonnet integration** - Uses Anthropic's latest model for intelligent compression
16
+ - **Reasoning display** - Shows what was compressed and how (optional)
17
+ - **Session management** - Track multiple compression attempts
18
+
19
+ ## Prerequisites
20
+
21
+ - Node.js >= 18.0.0
22
+ - Anthropic API key
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ npm install -g @sidhxntt/token-squasher
28
+ ```
29
+
30
+ Or run directly with npx:
31
+
32
+ ```bash
33
+ npx @sidhxntt/token-squasher
34
+ ```
35
+
36
+ ## Configuration
37
+
38
+ Set your Anthropic API key as an environment variable:
39
+
40
+ ```bash
41
+ export ANTHROPIC_API_KEY=sk-ant-your-api-key-here
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ ### Interactive Mode
47
+
48
+ Start the REPL:
49
+
50
+ ```bash
51
+ token-squasher
52
+ ```
53
+
54
+ ### Commands
55
+
56
+ - `:stats` - Toggle token statistics display
57
+ - `:verbose` - Toggle compression reasoning display
58
+ - `:clear` - Clear screen and reset
59
+ - `:quit` or `:q` - Exit the application
60
+
61
+ ### Example Session
62
+
63
+ ```
64
+ token-squasher v2.0.0
65
+ Compress verbose system prompts. Keep logic. Crush tokens.
66
+
67
+ ✔ ANTHROPIC_API_KEY detected
68
+
69
+ Paste your system prompt and press Enter twice to squash.
70
+ Commands: :stats toggle stats :verbose toggle reasoning :quit exit
71
+ ──────────────────────────────────────────────────────────
72
+
73
+ Prompt #1 — paste prompt then Enter twice to squash
74
+ › You are a helpful AI assistant. Please analyze the user's input carefully
75
+ › and provide a comprehensive response that addresses all aspects of their
76
+ › question. Make sure to be thorough and considerate in your analysis.
77
+
78
+
79
+ ⠋ Squashing tokens...
80
+
81
+ ✔ Compressed successfully
82
+
83
+ Analyze user input comprehensively. Address all question aspects thoroughly.
84
+
85
+ ───── TOKEN STATS ─────
86
+ Before 47 tokens (187 chars)
87
+ After 12 tokens (74 chars)
88
+ Crushed 74.5% ████████████████████░░░░
89
+ ───────────────────────
90
+ ```
91
+
92
+ ### Input Methods
93
+
94
+ 1. **Multi-line paste** - Paste your prompt and press Enter twice
95
+ 2. **Line-by-line** - Type each line, pressing Enter between lines, then Enter twice to finish
96
+
97
+ ## API Reference
98
+
99
+ The core compression function:
100
+
101
+ ```javascript
102
+ async function squashPrompt(promptText)
103
+ ```
104
+
105
+ **Parameters:**
106
+ - `promptText` (string) - The verbose system prompt to compress
107
+
108
+ **Returns:**
109
+ - Object with `squashed` (string) and `reasoning` (string) properties
110
+
111
+ **Model:** Uses `claude-sonnet-4-20250514` with max 4096 tokens
112
+
113
+ ## Project Structure
114
+
115
+ ```
116
+ token_quasher/
117
+ ├── index.js # Main CLI application with REPL
118
+ ├── package.json # NPM package configuration
119
+ └── package-lock.json # Dependency lock file
120
+ ```
121
+
122
+ ### Key Files
123
+
124
+ - **`index.js`** - Complete CLI implementation with Anthropic integration, REPL interface, and token estimation
125
+ - **`package.json`** - Defines the package as a global CLI tool with Node.js 18+ requirement
126
+
127
+ ## License
128
+
129
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sidhxntt/token-squasher",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Compress verbose system prompts into dense, token-efficient instructions without losing logic",
5
5
  "type": "module",
6
6
  "bin": {
@@ -27,4 +27,4 @@
27
27
  ],
28
28
  "author": "",
29
29
  "license": "MIT"
30
- }
30
+ }