squeezr-ai 1.16.13 → 1.16.15

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 +51 -35
  2. package/package.json +1 -1
package/bin/squeezr.js CHANGED
@@ -107,6 +107,53 @@ function printEnvRefreshHint(port, mitmPort) {
107
107
  }
108
108
  }
109
109
 
110
+ /**
111
+ * Install/update the PowerShell wrapper function in $PROFILE so that
112
+ * env vars are auto-refreshed after squeezr start/setup/update.
113
+ */
114
+ function installPowerShellWrapper() {
115
+ if (process.platform !== 'win32') return
116
+ try {
117
+ const psProfilePath = execSync('powershell -NoProfile -Command "[Environment]::GetFolderPath(\'MyDocuments\') + \'\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1\'"', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim()
118
+ const psProfileDir = path.dirname(psProfilePath)
119
+ if (!fs.existsSync(psProfileDir)) fs.mkdirSync(psProfileDir, { recursive: true })
120
+ const psMarker = '# squeezr wrapper'
121
+ const psFunction = `${psMarker}
122
+ function squeezr {
123
+ $bin = (Get-Command squeezr.cmd -ErrorAction SilentlyContinue).Source
124
+ if (-not $bin) { $bin = (Get-Command squeezr -ErrorAction SilentlyContinue).Source }
125
+ & node $bin @args
126
+ if ($args[0] -match '^(start|setup|update)$') {
127
+ @('ANTHROPIC_BASE_URL','GEMINI_API_BASE_URL','HTTPS_PROXY','NODE_EXTRA_CA_CERTS') | ForEach-Object {
128
+ $v = [Environment]::GetEnvironmentVariable($_, 'User')
129
+ if ($v) { [Environment]::SetEnvironmentVariable($_, $v, 'Process') }
130
+ }
131
+ }
132
+ if ($args[0] -eq 'stop') {
133
+ [Environment]::SetEnvironmentVariable('HTTPS_PROXY', $null, 'Process')
134
+ }
135
+ }
136
+ # end squeezr wrapper`
137
+ const existing = fs.existsSync(psProfilePath) ? fs.readFileSync(psProfilePath, 'utf-8') : ''
138
+ if (!existing.includes(psMarker)) {
139
+ fs.appendFileSync(psProfilePath, `\n${psFunction}\n`)
140
+ console.log(` [ok] PowerShell wrapper added to ${psProfilePath}`)
141
+ console.log('')
142
+ console.log(' ╔═══════════════════════════════════════════════════════════════╗')
143
+ console.log(' ║ ONE-TIME SETUP: Close this terminal and open a new one. ║')
144
+ console.log(' ║ This loads the wrapper that auto-refreshes env vars. ║')
145
+ console.log(' ║ After that, you will NEVER need to do this again. ║')
146
+ console.log(' ╚═══════════════════════════════════════════════════════════════╝')
147
+ } else {
148
+ const updated = existing.replace(/# squeezr wrapper[\s\S]*?# end squeezr wrapper/, psFunction)
149
+ fs.writeFileSync(psProfilePath, updated)
150
+ console.log(` [ok] PowerShell wrapper updated in ${psProfilePath}`)
151
+ }
152
+ } catch {
153
+ console.log(` [skip] PowerShell profile wrapper could not be installed`)
154
+ }
155
+ }
156
+
110
157
  const HELP = `
111
158
  Squeezr v${pkg.version} — AI context compressor for Claude Code, Codex, Aider, Gemini CLI and Ollama
112
159
 
@@ -596,41 +643,8 @@ function setupWindows() {
596
643
  }
597
644
  }
598
645
 
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
- }
646
+ // 1b. Install PowerShell wrapper so env vars auto-refresh after start/setup/update
647
+ installPowerShellWrapper()
634
648
 
635
649
  // 2. Auto-start: try NSSM (Windows service, survives crashes) → fallback to Task Scheduler
636
650
  const logDir = path.join(os.homedir(), '.squeezr')
@@ -1178,6 +1192,8 @@ switch (command) {
1178
1192
  if (fs.existsSync(setxExe)) execSync(`"${setxExe}" HTTPS_PROXY "http://localhost:${startMitmPort}"`, { stdio: 'pipe' })
1179
1193
  } catch {}
1180
1194
  }
1195
+ // Ensure PowerShell wrapper is installed (so env vars refresh automatically)
1196
+ installPowerShellWrapper()
1181
1197
  printEnvRefreshHint(startPort, startMitmPort)
1182
1198
  })()
1183
1199
  break
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squeezr-ai",
3
- "version": "1.16.13",
3
+ "version": "1.16.15",
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",