squeezr-ai 1.16.4 → 1.16.6

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 +97 -33
  2. package/package.json +1 -1
package/bin/squeezr.js CHANGED
@@ -445,6 +445,16 @@ async function uninstall() {
445
445
  }
446
446
  } catch {}
447
447
  }
448
+ // Also clean .profile
449
+ const profilePath = path.join(os.homedir(), '.profile')
450
+ try {
451
+ const content = fs.readFileSync(profilePath, 'utf-8')
452
+ if (content.includes('# squeezr env vars')) {
453
+ const cleaned = content.replace(/\n?# squeezr env vars[^\n]*(\nexport [^\n]*)*/g, '')
454
+ fs.writeFileSync(profilePath, cleaned)
455
+ console.log(` [ok] Cleaned ${profilePath}`)
456
+ }
457
+ } catch {}
448
458
  }
449
459
 
450
460
  // 3. Remove CA from certificate stores
@@ -482,12 +492,22 @@ async function uninstall() {
482
492
  const tomlPath = path.join(ROOT, 'squeezr.toml')
483
493
  try { fs.unlinkSync(tomlPath) } catch {}
484
494
 
485
- console.log(`
486
- Done! Squeezr has been completely removed.
495
+ // 7. npm uninstall -g (clear HTTPS_PROXY first so npm doesn't hit dead proxy)
496
+ console.log(' [..] Uninstalling npm package...')
497
+ const cleanEnv = { ...process.env, HTTPS_PROXY: '', https_proxy: '', HTTP_PROXY: '', http_proxy: '' }
498
+ try {
499
+ execSync('npm uninstall -g squeezr-ai', { stdio: 'inherit', env: cleanEnv })
500
+ console.log(' [ok] npm package removed')
501
+ } catch {
502
+ try {
503
+ execSync('sudo npm uninstall -g squeezr-ai', { stdio: 'inherit', env: cleanEnv })
504
+ console.log(' [ok] npm package removed')
505
+ } catch {
506
+ console.log(' [warn] Could not uninstall npm package. Run manually: npm uninstall -g squeezr-ai')
507
+ }
508
+ }
487
509
 
488
- To finish, run:
489
- npm uninstall -g squeezr-ai
490
- `)
510
+ console.log('\nDone! Squeezr has been completely removed.\n')
491
511
  }
492
512
 
493
513
  // ── squeezr setup ─────────────────────────────────────────────────────────────
@@ -673,6 +693,33 @@ function setupUnix() {
673
693
  `fi`,
674
694
  ].join('\n')
675
695
  const marker = '# squeezr env vars'
696
+
697
+ // Env-only block (no auto-heal) for .profile — loaded by login shells
698
+ // before .bashrc's "case $-" interactive guard
699
+ const envOnlyBlock = [
700
+ `# squeezr env vars`,
701
+ `export ANTHROPIC_BASE_URL=http://localhost:${port}`,
702
+ `export openai_base_url=http://localhost:${port}`,
703
+ `export GEMINI_API_BASE_URL=http://localhost:${port}`,
704
+ `export HTTPS_PROXY=http://localhost:${mitmPort}`,
705
+ `export SSL_CERT_FILE=${bundlePath}`,
706
+ ].join('\n')
707
+
708
+ // Write env vars to ~/.profile (login shell — always loaded)
709
+ const profilePath = path.join(os.homedir(), '.profile')
710
+ try {
711
+ const profileContent = fs.existsSync(profilePath) ? fs.readFileSync(profilePath, 'utf-8') : ''
712
+ if (!profileContent.includes(marker)) {
713
+ fs.appendFileSync(profilePath, `\n${envOnlyBlock}\n`)
714
+ console.log(` [ok] Env vars added to ${profilePath}`)
715
+ } else {
716
+ const updated = profileContent.replace(/# squeezr env vars[\s\S]*?(?=\n(?!export )|\n*$)/, envOnlyBlock)
717
+ fs.writeFileSync(profilePath, updated)
718
+ console.log(` [ok] Env vars updated in ${profilePath}`)
719
+ }
720
+ } catch {}
721
+
722
+ // Write full block (env + auto-heal) to interactive shell profile
676
723
  const profiles = [
677
724
  path.join(os.homedir(), '.zshrc'),
678
725
  path.join(os.homedir(), '.bashrc'),
@@ -684,17 +731,12 @@ function setupUnix() {
684
731
  fs.appendFileSync(profile, `\n${shellBlock}\n`)
685
732
  console.log(` [ok] Env vars + auto-heal added to ${profile}`)
686
733
  } else {
687
- if (!existing.includes('SSL_CERT_FILE') || !existing.includes('squeezr MITM')) {
688
- // Re-write block to include MITM vars
689
- const updatedContent = existing.replace(
690
- /# squeezr env vars[\s\S]*?fi\n/,
691
- shellBlock + '\n'
692
- )
693
- fs.writeFileSync(profile, updatedContent)
694
- console.log(` [ok] Shell profile updated with MITM proxy vars`)
695
- } else {
696
- console.log(` [skip] Env vars + auto-heal already in ${profile}`)
697
- }
734
+ const updatedContent = existing.replace(
735
+ /# squeezr env vars[\s\S]*?fi\n?/,
736
+ shellBlock + '\n'
737
+ )
738
+ fs.writeFileSync(profile, updatedContent)
739
+ console.log(` [ok] Env vars + auto-heal updated in ${profile}`)
698
740
  }
699
741
 
700
742
  // 2a. macOS — launchd
@@ -805,6 +847,31 @@ function setupWSL() {
805
847
  `fi`,
806
848
  ].join('\n')
807
849
  const marker = '# squeezr env vars'
850
+
851
+ // Env-only block for .profile (loaded before .bashrc's interactive guard)
852
+ const envOnlyBlock = [
853
+ `# squeezr env vars`,
854
+ `export ANTHROPIC_BASE_URL=http://localhost:${port}`,
855
+ `export openai_base_url=http://localhost:${port}`,
856
+ `export GEMINI_API_BASE_URL=http://localhost:${port}`,
857
+ `export HTTPS_PROXY=http://localhost:${mitmPort}`,
858
+ `export SSL_CERT_FILE=${bundlePath}`,
859
+ ].join('\n')
860
+
861
+ const profilePath = path.join(os.homedir(), '.profile')
862
+ try {
863
+ const profileContent = fs.existsSync(profilePath) ? fs.readFileSync(profilePath, 'utf-8') : ''
864
+ if (!profileContent.includes(marker)) {
865
+ fs.appendFileSync(profilePath, `\n${envOnlyBlock}\n`)
866
+ console.log(` [ok] Env vars added to ${profilePath}`)
867
+ } else {
868
+ const updated = profileContent.replace(/# squeezr env vars[\s\S]*?(?=\n(?!export )|\n*$)/, envOnlyBlock)
869
+ fs.writeFileSync(profilePath, updated)
870
+ console.log(` [ok] Env vars updated in ${profilePath}`)
871
+ }
872
+ } catch {}
873
+
874
+ // Full block (env + auto-heal) in interactive shell profile
808
875
  const profiles = [
809
876
  path.join(os.homedir(), '.zshrc'),
810
877
  path.join(os.homedir(), '.bashrc'),
@@ -816,17 +883,12 @@ function setupWSL() {
816
883
  fs.appendFileSync(profile, `\n${shellBlock}\n`)
817
884
  console.log(` [ok] Env vars + auto-heal added to ${profile}`)
818
885
  } else {
819
- // Update existing block if missing MITM proxy vars
820
- if (!existing.includes('SSL_CERT_FILE') || !existing.includes('HTTPS_PROXY')) {
821
- const updatedContent = existing.replace(
822
- /# squeezr env vars[\s\S]*?fi\n/,
823
- shellBlock + '\n'
824
- )
825
- fs.writeFileSync(profile, updatedContent)
826
- console.log(` [ok] Shell profile updated with MITM proxy vars`)
827
- } else {
828
- console.log(` [skip] Env vars already in ${profile}`)
829
- }
886
+ const updatedContent = existing.replace(
887
+ /# squeezr env vars[\s\S]*?fi\n?/,
888
+ shellBlock + '\n'
889
+ )
890
+ fs.writeFileSync(profile, updatedContent)
891
+ console.log(` [ok] Env vars + auto-heal updated in ${profile}`)
830
892
  }
831
893
 
832
894
  // 2. Set Windows env vars via setx.exe (so Windows-launched CLIs see them)
@@ -967,19 +1029,21 @@ switch (command) {
967
1029
  await new Promise(r => setTimeout(r, 1000))
968
1030
 
969
1031
  console.log('Installing latest version...')
1032
+ const cleanEnv = { ...process.env, HTTPS_PROXY: '', https_proxy: '', HTTP_PROXY: '', http_proxy: '' }
970
1033
  try {
971
- const npmCmd = process.platform === 'win32' ? 'npm' : 'HTTPS_PROXY= npm'
972
- execSync(`${npmCmd} install -g squeezr-ai@latest`, { stdio: 'inherit' })
973
- } catch (e) {
974
- // On Unix, might need sudo
1034
+ execSync('npm install -g squeezr-ai@latest', { stdio: 'inherit', env: cleanEnv })
1035
+ } catch {
975
1036
  try {
976
- execSync('sudo HTTPS_PROXY= npm install -g squeezr-ai@latest', { stdio: 'inherit' })
1037
+ execSync('sudo npm install -g squeezr-ai@latest', { stdio: 'inherit', env: cleanEnv })
977
1038
  } catch {
978
- console.error('npm install failed. Try manually: npm install -g squeezr-ai')
1039
+ console.error('npm install failed. Try manually: HTTPS_PROXY= npm install -g squeezr-ai')
979
1040
  process.exit(1)
980
1041
  }
981
1042
  }
982
1043
 
1044
+ // Clear update check cache so it doesn't show stale banner
1045
+ try { fs.unlinkSync(UPDATE_CHECK_FILE) } catch {}
1046
+
983
1047
  console.log('\nStarting Squeezr...')
984
1048
  // Re-exec the new binary so we run the updated code
985
1049
  const squeezrBin = process.argv[1]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squeezr-ai",
3
- "version": "1.16.4",
3
+ "version": "1.16.6",
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",