squeezr-ai 1.16.11 → 1.16.13
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 +77 -16
- package/package.json +1 -1
package/bin/squeezr.js
CHANGED
|
@@ -89,6 +89,24 @@ function getPort() {
|
|
|
89
89
|
return process.env.SQUEEZR_PORT || getPortFromToml() || 8080
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Print a PowerShell/bash one-liner to refresh env vars in the current session.
|
|
94
|
+
* Copies it to the clipboard on Windows so the user can just Ctrl+V, Enter.
|
|
95
|
+
*/
|
|
96
|
+
function printEnvRefreshHint(port, mitmPort) {
|
|
97
|
+
const bundlePath = path.join(os.homedir(), '.squeezr', 'mitm-ca', 'bundle.crt')
|
|
98
|
+
if (process.platform === 'win32') {
|
|
99
|
+
const cmd = `$env:ANTHROPIC_BASE_URL="http://localhost:${port}"; $env:GEMINI_API_BASE_URL="http://localhost:${port}"; $env:HTTPS_PROXY="http://localhost:${mitmPort}"`
|
|
100
|
+
try { execSync(`powershell -NoProfile -Command "Set-Clipboard '${cmd.replace(/'/g, "''")}';"`, { stdio: 'pipe' }) } catch {}
|
|
101
|
+
console.log(`\n Run this to activate in the current terminal (already copied to clipboard):\n`)
|
|
102
|
+
console.log(` ${cmd}\n`)
|
|
103
|
+
} else if (isWSL()) {
|
|
104
|
+
const cmd = `export ANTHROPIC_BASE_URL=http://localhost:${port} GEMINI_API_BASE_URL=http://localhost:${port} HTTPS_PROXY=http://localhost:${mitmPort} SSL_CERT_FILE=${bundlePath}`
|
|
105
|
+
console.log(`\n Run this to activate in the current terminal:\n`)
|
|
106
|
+
console.log(` ${cmd}\n`)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
92
110
|
const HELP = `
|
|
93
111
|
Squeezr v${pkg.version} — AI context compressor for Claude Code, Codex, Aider, Gemini CLI and Ollama
|
|
94
112
|
|
|
@@ -187,6 +205,7 @@ async function startDaemon() {
|
|
|
187
205
|
if (fs.existsSync(setxExe)) execSync(`"${setxExe}" HTTPS_PROXY "http://localhost:${mitmPort}"`, { stdio: 'pipe' })
|
|
188
206
|
} catch {}
|
|
189
207
|
}
|
|
208
|
+
printEnvRefreshHint(port, mitmPort)
|
|
190
209
|
}
|
|
191
210
|
|
|
192
211
|
function showLogs() {
|
|
@@ -512,7 +531,22 @@ async function uninstall() {
|
|
|
512
531
|
const tomlPath = path.join(ROOT, 'squeezr.toml')
|
|
513
532
|
try { fs.unlinkSync(tomlPath) } catch {}
|
|
514
533
|
|
|
515
|
-
// 7.
|
|
534
|
+
// 7. Remove PowerShell wrapper function from profile
|
|
535
|
+
if (process.platform === 'win32') {
|
|
536
|
+
try {
|
|
537
|
+
const psProfilePath = execSync('powershell -NoProfile -Command "[Environment]::GetFolderPath(\'MyDocuments\') + \'\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1\'"', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim()
|
|
538
|
+
if (fs.existsSync(psProfilePath)) {
|
|
539
|
+
const content = fs.readFileSync(psProfilePath, 'utf-8')
|
|
540
|
+
if (content.includes('# squeezr wrapper')) {
|
|
541
|
+
const cleaned = content.replace(/\n?# squeezr wrapper[\s\S]*?# end squeezr wrapper\n?/g, '')
|
|
542
|
+
fs.writeFileSync(psProfilePath, cleaned)
|
|
543
|
+
console.log(` [ok] Removed PowerShell wrapper from ${psProfilePath}`)
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
} catch {}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// 8. npm uninstall -g (clear HTTPS_PROXY first so npm doesn't hit dead proxy)
|
|
516
550
|
console.log(' [..] Uninstalling npm package...')
|
|
517
551
|
const cleanEnv = { ...process.env, HTTPS_PROXY: '', https_proxy: '', HTTP_PROXY: '', http_proxy: '' }
|
|
518
552
|
try {
|
|
@@ -562,6 +596,42 @@ function setupWindows() {
|
|
|
562
596
|
}
|
|
563
597
|
}
|
|
564
598
|
|
|
599
|
+
// 1b. Install PowerShell wrapper function so env vars are refreshed automatically
|
|
600
|
+
// after squeezr start/setup/update (child processes can't modify parent env).
|
|
601
|
+
try {
|
|
602
|
+
const psProfilePath = execSync('powershell -NoProfile -Command "[Environment]::GetFolderPath(\'MyDocuments\') + \'\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1\'"', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim()
|
|
603
|
+
const psProfileDir = path.dirname(psProfilePath)
|
|
604
|
+
if (!fs.existsSync(psProfileDir)) fs.mkdirSync(psProfileDir, { recursive: true })
|
|
605
|
+
const psMarker = '# squeezr wrapper'
|
|
606
|
+
const psFunction = `${psMarker}
|
|
607
|
+
function squeezr {
|
|
608
|
+
$bin = (Get-Command squeezr.cmd -ErrorAction SilentlyContinue).Source
|
|
609
|
+
if (-not $bin) { $bin = (Get-Command squeezr -ErrorAction SilentlyContinue).Source }
|
|
610
|
+
& node $bin @args
|
|
611
|
+
if ($args[0] -match '^(start|setup|update)$') {
|
|
612
|
+
@('ANTHROPIC_BASE_URL','GEMINI_API_BASE_URL','HTTPS_PROXY','NODE_EXTRA_CA_CERTS') | ForEach-Object {
|
|
613
|
+
$v = [Environment]::GetEnvironmentVariable($_, 'User')
|
|
614
|
+
if ($v) { [Environment]::SetEnvironmentVariable($_, $v, 'Process') }
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
if ($args[0] -eq 'stop') {
|
|
618
|
+
[Environment]::SetEnvironmentVariable('HTTPS_PROXY', $null, 'Process')
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
# end squeezr wrapper`
|
|
622
|
+
const existing = fs.existsSync(psProfilePath) ? fs.readFileSync(psProfilePath, 'utf-8') : ''
|
|
623
|
+
if (!existing.includes(psMarker)) {
|
|
624
|
+
fs.appendFileSync(psProfilePath, `\n${psFunction}\n`)
|
|
625
|
+
console.log(` [ok] PowerShell wrapper added to ${psProfilePath}`)
|
|
626
|
+
} else {
|
|
627
|
+
const updated = existing.replace(/# squeezr wrapper[\s\S]*?# end squeezr wrapper/, psFunction)
|
|
628
|
+
fs.writeFileSync(psProfilePath, updated)
|
|
629
|
+
console.log(` [ok] PowerShell wrapper updated in ${psProfilePath}`)
|
|
630
|
+
}
|
|
631
|
+
} catch (err) {
|
|
632
|
+
console.log(` [skip] PowerShell profile wrapper could not be installed`)
|
|
633
|
+
}
|
|
634
|
+
|
|
565
635
|
// 2. Auto-start: try NSSM (Windows service, survives crashes) → fallback to Task Scheduler
|
|
566
636
|
const logDir = path.join(os.homedir(), '.squeezr')
|
|
567
637
|
const serviceName = 'SqueezrProxy'
|
|
@@ -677,12 +747,10 @@ Done!
|
|
|
677
747
|
MITM proxy on http://localhost:${mitmPort} (Codex TLS interception)
|
|
678
748
|
All CLIs (Claude Code, Codex, Aider, Gemini, Ollama) are configured.
|
|
679
749
|
|
|
680
|
-
Restart your terminal once for the env vars to take effect.
|
|
681
|
-
After that, everything is automatic — Squeezr starts silently on every login.
|
|
682
|
-
|
|
683
750
|
squeezr status — check it's running
|
|
684
751
|
squeezr gain — see token savings
|
|
685
752
|
`)
|
|
753
|
+
printEnvRefreshHint(port, mitmPort)
|
|
686
754
|
}
|
|
687
755
|
}
|
|
688
756
|
|
|
@@ -999,26 +1067,21 @@ WantedBy=default.target
|
|
|
999
1067
|
console.log(` [ok] Squeezr started in background (pid ${child.pid})`)
|
|
1000
1068
|
console.log(` [ok] Logs → ${logFile}`)
|
|
1001
1069
|
|
|
1002
|
-
|
|
1003
|
-
|
|
1070
|
+
const setupPort = getPort()
|
|
1071
|
+
const setupMitmPort = getMitmPort(setupPort)
|
|
1004
1072
|
console.log(`
|
|
1005
1073
|
Done!
|
|
1006
1074
|
|
|
1007
|
-
Squeezr is running on http://localhost
|
|
1075
|
+
Squeezr is running on http://localhost:${setupPort}
|
|
1008
1076
|
All CLIs (Claude Code, Codex, Aider, Gemini, Ollama) are configured.
|
|
1009
1077
|
|
|
1010
1078
|
Windows env vars are set (effective in new terminals immediately).
|
|
1011
1079
|
WSL env vars added to ${profile}.
|
|
1012
1080
|
|
|
1013
|
-
To activate in THIS terminal: source ${profile}
|
|
1014
|
-
|
|
1015
|
-
⚠️ IMPORTANT: Close this terminal and open a new one so the
|
|
1016
|
-
environment variables take effect. Otherwise tools like
|
|
1017
|
-
Claude Code may fail with 502 errors.
|
|
1018
|
-
|
|
1019
1081
|
squeezr status — check it's running
|
|
1020
1082
|
squeezr gain — see token savings
|
|
1021
1083
|
`)
|
|
1084
|
+
printEnvRefreshHint(setupPort, setupMitmPort)
|
|
1022
1085
|
}
|
|
1023
1086
|
|
|
1024
1087
|
// ── CLI router ────────────────────────────────────────────────────────────────
|
|
@@ -1114,10 +1177,8 @@ switch (command) {
|
|
|
1114
1177
|
const setxExe = '/mnt/c/Windows/System32/setx.exe'
|
|
1115
1178
|
if (fs.existsSync(setxExe)) execSync(`"${setxExe}" HTTPS_PROXY "http://localhost:${startMitmPort}"`, { stdio: 'pipe' })
|
|
1116
1179
|
} catch {}
|
|
1117
|
-
console.log('\n ⚠️ IMPORTANT: Close this terminal and open a new one so the')
|
|
1118
|
-
console.log(' environment variables take effect. Otherwise tools like')
|
|
1119
|
-
console.log(' Claude Code may fail with 502 errors.\n')
|
|
1120
1180
|
}
|
|
1181
|
+
printEnvRefreshHint(startPort, startMitmPort)
|
|
1121
1182
|
})()
|
|
1122
1183
|
break
|
|
1123
1184
|
case 'stop':
|
package/package.json
CHANGED