squeezr-ai 1.10.0 → 1.10.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.
package/bin/squeezr.js CHANGED
@@ -1,33 +1,29 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict'
3
3
 
4
- const { spawn } = require('child_process')
4
+ const { spawn, execSync } = require('child_process')
5
5
  const http = require('http')
6
6
  const path = require('path')
7
7
  const fs = require('fs')
8
+ const os = require('os')
8
9
 
9
10
  const ROOT = path.join(__dirname, '..')
10
11
  const args = process.argv.slice(2)
11
12
  const command = args[0]
12
13
 
13
14
  const HELP = `
14
- Squeezr v1.8.0 — AI context compressor for Claude Code, Codex, Aider, Gemini CLI and Ollama
15
+ Squeezr v1.10.0 — AI context compressor for Claude Code, Codex, Aider, Gemini CLI and Ollama
15
16
 
16
17
  Usage:
17
18
  squeezr Start the proxy (default)
18
19
  squeezr start Start the proxy
20
+ squeezr setup One-time setup: auto-start on login + configure all CLIs
19
21
  squeezr gain Show token savings stats
20
22
  squeezr gain --reset Reset saved stats
21
23
  squeezr discover Show pattern coverage report (proxy must be running)
22
24
  squeezr status Check if proxy is running
23
25
  squeezr config Print config file path and current settings
24
26
  squeezr help Show this help
25
-
26
- Set your CLI to use Squeezr:
27
- Claude Code: ANTHROPIC_BASE_URL=http://localhost:8080
28
- Codex / Aider: OPENAI_BASE_URL=http://localhost:8080
29
- Gemini CLI: GEMINI_API_BASE_URL=http://localhost:8080
30
- Ollama: OPENAI_BASE_URL=http://localhost:8080
31
27
  `
32
28
 
33
29
  function runNode(script, extraArgs = []) {
@@ -82,12 +78,185 @@ function showConfig() {
82
78
  }
83
79
  }
84
80
 
81
+ // ── squeezr setup ─────────────────────────────────────────────────────────────
82
+
83
+ function setupWindows() {
84
+ const squeezrBin = process.argv[1] // full path to this script
85
+ const nodeExe = process.execPath // full path to node.exe
86
+
87
+ console.log('Setting up Squeezr for Windows...\n')
88
+
89
+ // 1. Set env vars permanently via setx (user scope, no admin needed)
90
+ const vars = {
91
+ ANTHROPIC_BASE_URL: 'http://localhost:8080',
92
+ OPENAI_BASE_URL: 'http://localhost:8080',
93
+ GEMINI_API_BASE_URL: 'http://localhost:8080',
94
+ }
95
+ for (const [key, value] of Object.entries(vars)) {
96
+ try {
97
+ execSync(`setx ${key} "${value}"`, { stdio: 'pipe' })
98
+ console.log(` [ok] ${key}=${value}`)
99
+ } catch {
100
+ console.log(` [skip] ${key} already set or could not be set`)
101
+ }
102
+ }
103
+
104
+ // 2. Register Task Scheduler (auto-start on login, restart on failure)
105
+ const taskName = 'Squeezr'
106
+ const ps = `
107
+ $existing = Get-ScheduledTask -TaskName '${taskName}' -ErrorAction SilentlyContinue
108
+ if ($existing) { Unregister-ScheduledTask -TaskName '${taskName}' -Confirm:$false }
109
+ $action = New-ScheduledTaskAction -Execute '${nodeExe}' -Argument '"${squeezrBin}"'
110
+ $trigger = New-ScheduledTaskTrigger -AtLogon
111
+ $settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit 0 -RestartCount 5 -RestartInterval (New-TimeSpan -Minutes 1)
112
+ Register-ScheduledTask -TaskName '${taskName}' -Action $action -Trigger $trigger -Settings $settings -RunLevel Highest -Force | Out-Null
113
+ Start-ScheduledTask -TaskName '${taskName}'
114
+ `
115
+ try {
116
+ execSync(`powershell -NoProfile -Command "${ps.replace(/\n/g, ' ')}"`, { stdio: 'pipe' })
117
+ console.log(` [ok] Auto-start registered in Task Scheduler`)
118
+ console.log(` [ok] Squeezr started now`)
119
+ } catch (e) {
120
+ console.log(` [warn] Could not register Task Scheduler (try running as admin):`)
121
+ console.log(` ${e.message?.split('\n')[0]}`)
122
+ console.log(` Starting Squeezr manually instead...`)
123
+ spawn(nodeExe, [squeezrBin, 'start'], { detached: true, stdio: 'ignore' }).unref()
124
+ }
125
+
126
+ console.log(`
127
+ Done!
128
+
129
+ Squeezr is running on http://localhost:8080
130
+ All CLIs (Claude Code, Codex, Aider, Gemini, Ollama) are configured.
131
+
132
+ IMPORTANT: Restart your terminal and Claude Code once for the
133
+ env vars to take effect. After that, everything is automatic.
134
+
135
+ squeezr status — check it's running
136
+ squeezr gain — see token savings
137
+ `)
138
+ }
139
+
140
+ function setupUnix() {
141
+ const squeezrBin = process.argv[1]
142
+ const nodeExe = process.execPath
143
+ const platform = process.platform
144
+
145
+ console.log(`Setting up Squeezr for ${platform === 'darwin' ? 'macOS' : 'Linux'}...\n`)
146
+
147
+ // 1. Set env vars in shell profile
148
+ const exportLines = [
149
+ 'export ANTHROPIC_BASE_URL=http://localhost:8080',
150
+ 'export OPENAI_BASE_URL=http://localhost:8080',
151
+ 'export GEMINI_API_BASE_URL=http://localhost:8080',
152
+ ]
153
+ const marker = '# squeezr env vars'
154
+
155
+ // Detect shell profile
156
+ const profiles = [
157
+ path.join(os.homedir(), '.zshrc'),
158
+ path.join(os.homedir(), '.bashrc'),
159
+ path.join(os.homedir(), '.bash_profile'),
160
+ ]
161
+ const profile = profiles.find(p => fs.existsSync(p)) ?? profiles[0]
162
+
163
+ const existing = fs.existsSync(profile) ? fs.readFileSync(profile, 'utf-8') : ''
164
+ if (!existing.includes(marker)) {
165
+ const block = `\n${marker}\n${exportLines.join('\n')}\n`
166
+ fs.appendFileSync(profile, block)
167
+ console.log(` [ok] Env vars added to ${profile}`)
168
+ } else {
169
+ console.log(` [skip] Env vars already in ${profile}`)
170
+ }
171
+
172
+ // 2a. macOS — launchd plist
173
+ if (platform === 'darwin') {
174
+ const plistDir = path.join(os.homedir(), 'Library', 'LaunchAgents')
175
+ const plistPath = path.join(plistDir, 'com.squeezr.plist')
176
+ fs.mkdirSync(plistDir, { recursive: true })
177
+ fs.writeFileSync(plistPath, `<?xml version="1.0" encoding="UTF-8"?>
178
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
179
+ <plist version="1.0">
180
+ <dict>
181
+ <key>Label</key><string>com.squeezr</string>
182
+ <key>ProgramArguments</key>
183
+ <array><string>${nodeExe}</string><string>${squeezrBin}</string></array>
184
+ <key>RunAtLoad</key><true/>
185
+ <key>KeepAlive</key><true/>
186
+ <key>StandardOutPath</key><string>${os.homedir()}/.squeezr/squeezr.log</string>
187
+ <key>StandardErrorPath</key><string>${os.homedir()}/.squeezr/squeezr.log</string>
188
+ </dict>
189
+ </plist>`)
190
+ try {
191
+ execSync(`launchctl unload "${plistPath}" 2>/dev/null; launchctl load "${plistPath}"`, { stdio: 'pipe' })
192
+ console.log(` [ok] Auto-start registered via launchd`)
193
+ console.log(` [ok] Squeezr started now`)
194
+ } catch {
195
+ console.log(` [warn] launchctl failed — starting manually`)
196
+ spawn(nodeExe, [squeezrBin, 'start'], { detached: true, stdio: 'ignore' }).unref()
197
+ }
198
+
199
+ // 2b. Linux — systemd user service
200
+ } else {
201
+ const serviceDir = path.join(os.homedir(), '.config', 'systemd', 'user')
202
+ const servicePath = path.join(serviceDir, 'squeezr.service')
203
+ fs.mkdirSync(serviceDir, { recursive: true })
204
+ fs.writeFileSync(servicePath, `[Unit]
205
+ Description=Squeezr AI proxy
206
+ After=network.target
207
+
208
+ [Service]
209
+ ExecStart=${nodeExe} ${squeezrBin}
210
+ Restart=always
211
+ RestartSec=5
212
+
213
+ [Install]
214
+ WantedBy=default.target
215
+ `)
216
+ try {
217
+ execSync('systemctl --user daemon-reload && systemctl --user enable --now squeezr', { stdio: 'pipe' })
218
+ console.log(` [ok] Auto-start registered via systemd`)
219
+ console.log(` [ok] Squeezr started now`)
220
+ } catch {
221
+ console.log(` [warn] systemctl failed — starting manually`)
222
+ spawn(nodeExe, [squeezrBin, 'start'], { detached: true, stdio: 'ignore' }).unref()
223
+ }
224
+ }
225
+
226
+ console.log(`
227
+ Done!
228
+
229
+ Squeezr is running on http://localhost:8080
230
+ All CLIs (Claude Code, Codex, Aider, Gemini, Ollama) are configured.
231
+
232
+ IMPORTANT: Run 'source ${profile}' or open a new terminal once
233
+ for the env vars to take effect. After that, everything is automatic.
234
+
235
+ squeezr status — check it's running
236
+ squeezr gain — see token savings
237
+ `)
238
+ }
239
+
240
+ function runSetup() {
241
+ if (process.platform === 'win32') {
242
+ setupWindows()
243
+ } else {
244
+ setupUnix()
245
+ }
246
+ }
247
+
248
+ // ── CLI router ────────────────────────────────────────────────────────────────
249
+
85
250
  switch (command) {
86
251
  case undefined:
87
252
  case 'start':
88
253
  runNode('index.js')
89
254
  break
90
255
 
256
+ case 'setup':
257
+ runSetup()
258
+ break
259
+
91
260
  case 'gain':
92
261
  runNode('gain.js', args.slice(1))
93
262
  break
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.10.0";
1
+ export declare const VERSION = "1.10.1";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.10.0';
1
+ export const VERSION = '1.10.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squeezr-ai",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
4
4
  "description": "AI proxy that compresses Claude Code, Codex, Aider, Gemini CLI and Ollama context windows to save thousands of tokens per session",
5
5
  "keywords": [
6
6
  "claude",