squeezr-ai 1.16.15 → 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 +75 -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)
@@ -578,7 +635,7 @@ async function uninstall() {
578
635
  const tomlPath = path.join(ROOT, 'squeezr.toml')
579
636
  try { fs.unlinkSync(tomlPath) } catch {}
580
637
 
581
- // 7. Remove PowerShell wrapper function from profile
638
+ // 7. Remove shell wrapper functions from profiles
582
639
  if (process.platform === 'win32') {
583
640
  try {
584
641
  const psProfilePath = execSync('powershell -NoProfile -Command "[Environment]::GetFolderPath(\'MyDocuments\') + \'\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1\'"', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim()
@@ -592,6 +649,17 @@ async function uninstall() {
592
649
  }
593
650
  } catch {}
594
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
+ }
595
663
 
596
664
  // 8. npm uninstall -g (clear HTTPS_PROXY first so npm doesn't hit dead proxy)
597
665
  console.log(' [..] Uninstalling npm package...')
@@ -644,7 +712,7 @@ function setupWindows() {
644
712
  }
645
713
 
646
714
  // 1b. Install PowerShell wrapper so env vars auto-refresh after start/setup/update
647
- installPowerShellWrapper()
715
+ installShellWrapper()
648
716
 
649
717
  // 2. Auto-start: try NSSM (Windows service, survives crashes) → fallback to Task Scheduler
650
718
  const logDir = path.join(os.homedir(), '.squeezr')
@@ -1193,7 +1261,7 @@ switch (command) {
1193
1261
  } catch {}
1194
1262
  }
1195
1263
  // Ensure PowerShell wrapper is installed (so env vars refresh automatically)
1196
- installPowerShellWrapper()
1264
+ installShellWrapper()
1197
1265
  printEnvRefreshHint(startPort, startMitmPort)
1198
1266
  })()
1199
1267
  break
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squeezr-ai",
3
- "version": "1.16.15",
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",