squeezr-ai 1.16.12 → 1.16.14

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 +62 -1
  2. package/package.json +1 -1
package/bin/squeezr.js CHANGED
@@ -107,6 +107,47 @@ 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
+ } else {
142
+ const updated = existing.replace(/# squeezr wrapper[\s\S]*?# end squeezr wrapper/, psFunction)
143
+ fs.writeFileSync(psProfilePath, updated)
144
+ console.log(` [ok] PowerShell wrapper updated in ${psProfilePath}`)
145
+ }
146
+ } catch {
147
+ console.log(` [skip] PowerShell profile wrapper could not be installed`)
148
+ }
149
+ }
150
+
110
151
  const HELP = `
111
152
  Squeezr v${pkg.version} — AI context compressor for Claude Code, Codex, Aider, Gemini CLI and Ollama
112
153
 
@@ -531,7 +572,22 @@ async function uninstall() {
531
572
  const tomlPath = path.join(ROOT, 'squeezr.toml')
532
573
  try { fs.unlinkSync(tomlPath) } catch {}
533
574
 
534
- // 7. npm uninstall -g (clear HTTPS_PROXY first so npm doesn't hit dead proxy)
575
+ // 7. Remove PowerShell wrapper function from profile
576
+ if (process.platform === 'win32') {
577
+ try {
578
+ const psProfilePath = execSync('powershell -NoProfile -Command "[Environment]::GetFolderPath(\'MyDocuments\') + \'\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1\'"', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim()
579
+ if (fs.existsSync(psProfilePath)) {
580
+ const content = fs.readFileSync(psProfilePath, 'utf-8')
581
+ if (content.includes('# squeezr wrapper')) {
582
+ const cleaned = content.replace(/\n?# squeezr wrapper[\s\S]*?# end squeezr wrapper\n?/g, '')
583
+ fs.writeFileSync(psProfilePath, cleaned)
584
+ console.log(` [ok] Removed PowerShell wrapper from ${psProfilePath}`)
585
+ }
586
+ }
587
+ } catch {}
588
+ }
589
+
590
+ // 8. npm uninstall -g (clear HTTPS_PROXY first so npm doesn't hit dead proxy)
535
591
  console.log(' [..] Uninstalling npm package...')
536
592
  const cleanEnv = { ...process.env, HTTPS_PROXY: '', https_proxy: '', HTTP_PROXY: '', http_proxy: '' }
537
593
  try {
@@ -581,6 +637,9 @@ function setupWindows() {
581
637
  }
582
638
  }
583
639
 
640
+ // 1b. Install PowerShell wrapper so env vars auto-refresh after start/setup/update
641
+ installPowerShellWrapper()
642
+
584
643
  // 2. Auto-start: try NSSM (Windows service, survives crashes) → fallback to Task Scheduler
585
644
  const logDir = path.join(os.homedir(), '.squeezr')
586
645
  const serviceName = 'SqueezrProxy'
@@ -1127,6 +1186,8 @@ switch (command) {
1127
1186
  if (fs.existsSync(setxExe)) execSync(`"${setxExe}" HTTPS_PROXY "http://localhost:${startMitmPort}"`, { stdio: 'pipe' })
1128
1187
  } catch {}
1129
1188
  }
1189
+ // Ensure PowerShell wrapper is installed (so env vars refresh automatically)
1190
+ installPowerShellWrapper()
1130
1191
  printEnvRefreshHint(startPort, startMitmPort)
1131
1192
  })()
1132
1193
  break
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squeezr-ai",
3
- "version": "1.16.12",
3
+ "version": "1.16.14",
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",