squeezr-ai 1.16.14 → 1.16.16

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/bin/squeezr.js +81 -7
  2. package/package.json +1 -1
package/bin/squeezr.js CHANGED
@@ -108,11 +108,68 @@ function printEnvRefreshHint(port, mitmPort) {
108
108
  }
109
109
 
110
110
  /**
111
- * Install/update the PowerShell wrapper function in $PROFILE so that
112
- * env vars are auto-refreshed after squeezr start/setup/update.
111
+ * Install/update shell wrapper functions so env vars are auto-refreshed
112
+ * after squeezr start/setup/update (child processes can't modify parent env).
113
113
  */
114
- function installPowerShellWrapper() {
115
- if (process.platform !== 'win32') return
114
+ function installShellWrapper() {
115
+ if (process.platform === 'win32') return installShellWrapper()
116
+ if (isWSL() || process.platform === 'linux' || process.platform === 'darwin') return installBashWrapper()
117
+ }
118
+
119
+ function installBashWrapper() {
120
+ const port = getPort()
121
+ const mitmPort = getMitmPort(port)
122
+ const bundlePath = path.join(os.homedir(), '.squeezr', 'mitm-ca', 'bundle.crt')
123
+ const marker = '# squeezr shell wrapper'
124
+ const endMarker = '# end squeezr shell wrapper'
125
+ const wrapper = `${marker}
126
+ squeezr() {
127
+ command squeezr "$@"
128
+ case "$1" in
129
+ start|setup|update)
130
+ export ANTHROPIC_BASE_URL=http://localhost:${port}
131
+ export GEMINI_API_BASE_URL=http://localhost:${port}
132
+ export HTTPS_PROXY=http://localhost:${mitmPort}
133
+ export SSL_CERT_FILE=${bundlePath}
134
+ ;;
135
+ stop)
136
+ unset HTTPS_PROXY
137
+ ;;
138
+ esac
139
+ }
140
+ ${endMarker}`
141
+
142
+ const profiles = [
143
+ path.join(os.homedir(), '.bashrc'),
144
+ path.join(os.homedir(), '.zshrc'),
145
+ ]
146
+ let installed = false
147
+ for (const p of profiles) {
148
+ if (!fs.existsSync(p)) continue
149
+ try {
150
+ const content = fs.readFileSync(p, 'utf-8')
151
+ if (!content.includes(marker)) {
152
+ fs.appendFileSync(p, `\n${wrapper}\n`)
153
+ console.log(` [ok] Shell wrapper added to ${p}`)
154
+ installed = true
155
+ } else {
156
+ const updated = content.replace(new RegExp(`${marker.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\s\\S]*?${endMarker.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`), wrapper)
157
+ fs.writeFileSync(p, updated)
158
+ console.log(` [ok] Shell wrapper updated in ${p}`)
159
+ }
160
+ } catch {}
161
+ }
162
+ if (installed) {
163
+ console.log('')
164
+ console.log(' ╔═══════════════════════════════════════════════════════════════╗')
165
+ console.log(' ║ ONE-TIME SETUP: Close this terminal and open a new one. ║')
166
+ console.log(' ║ This loads the wrapper that auto-refreshes env vars. ║')
167
+ console.log(' ║ After that, you will NEVER need to do this again. ║')
168
+ console.log(' ╚═══════════════════════════════════════════════════════════════╝')
169
+ }
170
+ }
171
+
172
+ function installShellWrapper() {
116
173
  try {
117
174
  const psProfilePath = execSync('powershell -NoProfile -Command "[Environment]::GetFolderPath(\'MyDocuments\') + \'\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1\'"', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim()
118
175
  const psProfileDir = path.dirname(psProfilePath)
@@ -138,6 +195,12 @@ function squeezr {
138
195
  if (!existing.includes(psMarker)) {
139
196
  fs.appendFileSync(psProfilePath, `\n${psFunction}\n`)
140
197
  console.log(` [ok] PowerShell wrapper added to ${psProfilePath}`)
198
+ console.log('')
199
+ console.log(' ╔═══════════════════════════════════════════════════════════════╗')
200
+ console.log(' ║ ONE-TIME SETUP: Close this terminal and open a new one. ║')
201
+ console.log(' ║ This loads the wrapper that auto-refreshes env vars. ║')
202
+ console.log(' ║ After that, you will NEVER need to do this again. ║')
203
+ console.log(' ╚═══════════════════════════════════════════════════════════════╝')
141
204
  } else {
142
205
  const updated = existing.replace(/# squeezr wrapper[\s\S]*?# end squeezr wrapper/, psFunction)
143
206
  fs.writeFileSync(psProfilePath, updated)
@@ -572,7 +635,7 @@ async function uninstall() {
572
635
  const tomlPath = path.join(ROOT, 'squeezr.toml')
573
636
  try { fs.unlinkSync(tomlPath) } catch {}
574
637
 
575
- // 7. Remove PowerShell wrapper function from profile
638
+ // 7. Remove shell wrapper functions from profiles
576
639
  if (process.platform === 'win32') {
577
640
  try {
578
641
  const psProfilePath = execSync('powershell -NoProfile -Command "[Environment]::GetFolderPath(\'MyDocuments\') + \'\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1\'"', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim()
@@ -586,6 +649,17 @@ async function uninstall() {
586
649
  }
587
650
  } catch {}
588
651
  }
652
+ // Remove bash/zsh wrapper
653
+ for (const p of [path.join(os.homedir(), '.bashrc'), path.join(os.homedir(), '.zshrc')]) {
654
+ try {
655
+ const content = fs.readFileSync(p, 'utf-8')
656
+ if (content.includes('# squeezr shell wrapper')) {
657
+ const cleaned = content.replace(/\n?# squeezr shell wrapper[\s\S]*?# end squeezr shell wrapper\n?/g, '')
658
+ fs.writeFileSync(p, cleaned)
659
+ console.log(` [ok] Removed shell wrapper from ${p}`)
660
+ }
661
+ } catch {}
662
+ }
589
663
 
590
664
  // 8. npm uninstall -g (clear HTTPS_PROXY first so npm doesn't hit dead proxy)
591
665
  console.log(' [..] Uninstalling npm package...')
@@ -638,7 +712,7 @@ function setupWindows() {
638
712
  }
639
713
 
640
714
  // 1b. Install PowerShell wrapper so env vars auto-refresh after start/setup/update
641
- installPowerShellWrapper()
715
+ installShellWrapper()
642
716
 
643
717
  // 2. Auto-start: try NSSM (Windows service, survives crashes) → fallback to Task Scheduler
644
718
  const logDir = path.join(os.homedir(), '.squeezr')
@@ -1187,7 +1261,7 @@ switch (command) {
1187
1261
  } catch {}
1188
1262
  }
1189
1263
  // Ensure PowerShell wrapper is installed (so env vars refresh automatically)
1190
- installPowerShellWrapper()
1264
+ installShellWrapper()
1191
1265
  printEnvRefreshHint(startPort, startMitmPort)
1192
1266
  })()
1193
1267
  break
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squeezr-ai",
3
- "version": "1.16.14",
3
+ "version": "1.16.16",
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",