claude-glm-alt-installer 2.0.1 → 2.0.2

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 (3) hide show
  1. package/bin/cli.js +7 -2
  2. package/install.sh +154 -68
  3. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -4,6 +4,7 @@ import { spawn } from 'child_process';
4
4
  import path from 'path';
5
5
  import os from 'os';
6
6
  import fs from 'fs';
7
+ import tty from 'tty';
7
8
  import { fileURLToPath } from 'url';
8
9
 
9
10
  const __filename = fileURLToPath(import.meta.url);
@@ -19,6 +20,9 @@ console.log(`Detected OS: ${platform}\n`);
19
20
  function runInstaller() {
20
21
  let command, args, scriptPath;
21
22
 
23
+ // Check if running in interactive mode (TTY available)
24
+ const isInteractive = tty.isatty(0);
25
+
22
26
  if (platform === 'win32') {
23
27
  // Windows - run PowerShell installer
24
28
  console.log('🪟 Running Windows PowerShell installer...\n');
@@ -55,9 +59,10 @@ function runInstaller() {
55
59
  process.exit(1);
56
60
  }
57
61
 
58
- // Spawn the installer process
62
+ // For interactive mode, we need to pass stdin through properly
63
+ // Use 'inherit' for all stdio to allow user interaction
59
64
  const installer = spawn(command, args, {
60
- stdio: 'inherit',
65
+ stdio: ['inherit', 'inherit', 'inherit'],
61
66
  cwd: rootDir
62
67
  });
63
68
 
package/install.sh CHANGED
@@ -4,16 +4,23 @@
4
4
  #
5
5
  # Usage:
6
6
  # Test error reporting:
7
- # CLAUDE_GLM_TEST_ERROR=1 bash <(curl -fsSL https://raw.githubusercontent.com/JoeInnsp23/claude-glm-wrapper/main/install.sh)
7
+ # CLAUDE_GLM_TEST_ERROR=1 bash <(curl -fsSL https://raw.githubusercontent.com/MohMaya/claude-glm-wrapper/main/install.sh)
8
8
  # OR: ./install.sh --test-error
9
9
  #
10
10
  # Enable debug mode:
11
- # CLAUDE_GLM_DEBUG=1 bash <(curl -fsSL https://raw.githubusercontent.com/JoeInnsp23/claude-glm-wrapper/main/install.sh)
11
+ # CLAUDE_GLM_DEBUG=1 bash <(curl -fsSL https://raw.githubusercontent.com/MohMaya/claude-glm-wrapper/main/install.sh)
12
12
  # OR: ./install.sh --debug
13
+ #
14
+ # Non-interactive installation:
15
+ # ./install.sh --reinstall --api-key=YOUR_KEY
16
+ # ./install.sh --reinstall --skip-ccx
13
17
 
14
18
  # Parse command-line arguments
15
19
  TEST_ERROR=false
16
20
  DEBUG=false
21
+ REINSTALL=false
22
+ API_KEY_ARG=""
23
+ SKIP_CCX=false
17
24
 
18
25
  for arg in "$@"; do
19
26
  case $arg in
@@ -25,6 +32,18 @@ for arg in "$@"; do
25
32
  DEBUG=true
26
33
  shift
27
34
  ;;
35
+ --reinstall)
36
+ REINSTALL=true
37
+ shift
38
+ ;;
39
+ --skip-ccx)
40
+ SKIP_CCX=true
41
+ shift
42
+ ;;
43
+ --api-key=*)
44
+ API_KEY_ARG="${arg#*=}"
45
+ shift
46
+ ;;
28
47
  *)
29
48
  # Unknown option
30
49
  ;;
@@ -40,6 +59,18 @@ if [ "$CLAUDE_GLM_DEBUG" = "1" ] || [ "$CLAUDE_GLM_DEBUG" = "true" ]; then
40
59
  DEBUG=true
41
60
  fi
42
61
 
62
+ if [ "$CLAUDE_GLM_REINSTALL" = "1" ] || [ "$CLAUDE_GLM_REINSTALL" = "true" ]; then
63
+ REINSTALL=true
64
+ fi
65
+
66
+ # Detect if running in interactive mode (TTY available)
67
+ INTERACTIVE=true
68
+ if [ ! -t 0 ]; then
69
+ INTERACTIVE=false
70
+ # In non-interactive mode, default to reinstall
71
+ REINSTALL=true
72
+ fi
73
+
43
74
  # Configuration
44
75
  USER_BIN_DIR="$HOME/.local/bin"
45
76
  GLM_CONFIG_DIR="$HOME/.claude-glm"
@@ -82,15 +113,23 @@ report_error() {
82
113
  # Ask if user wants to report the error
83
114
  echo "Would you like to report this error to GitHub?"
84
115
  echo "This will open your browser with a pre-filled issue report."
85
- read -p "Report error? (y/n): " report_choice
116
+
117
+ local report_choice="n"
118
+ if [ "$INTERACTIVE" = true ]; then
119
+ read -p "Report error? (y/n): " report_choice
120
+ else
121
+ echo "ℹ️ Non-interactive mode: skipping error report prompt"
122
+ fi
86
123
  echo ""
87
124
 
88
125
  if [ "$report_choice" != "y" ] && [ "$report_choice" != "Y" ]; then
89
126
  echo "Error not reported. You can get help at:"
90
- echo " https://github.com/JoeInnsp23/claude-glm-wrapper/issues"
91
- echo ""
92
- echo "Press Enter to finish..."
93
- read
127
+ echo " https://github.com/MohMaya/claude-glm-wrapper/issues"
128
+ if [ "$INTERACTIVE" = true ]; then
129
+ echo ""
130
+ echo "Press Enter to finish..."
131
+ read
132
+ fi
94
133
  return
95
134
  fi
96
135
 
@@ -151,7 +190,7 @@ $sanitized_error
151
190
  encoded_title="Installation%20Error%3A%20Unix%2FLinux%2FmacOS"
152
191
  fi
153
192
 
154
- local issue_url="https://github.com/JoeInnsp23/claude-glm-wrapper/issues/new?title=${encoded_title}&body=${encoded_body}&labels=bug,unix,installation"
193
+ local issue_url="https://github.com/MohMaya/claude-glm-wrapper/issues/new?title=${encoded_title}&body=${encoded_body}&labels=bug,unix,installation"
155
194
 
156
195
  echo "📋 Error details have been prepared for reporting."
157
196
  echo ""
@@ -185,9 +224,11 @@ $sanitized_error
185
224
  echo "After submitting (or if you choose not to), return here."
186
225
  fi
187
226
 
188
- echo ""
189
- echo "Press Enter to continue..."
190
- read
227
+ if [ "$INTERACTIVE" = true ]; then
228
+ echo ""
229
+ echo "Press Enter to continue..."
230
+ read
231
+ fi
191
232
  }
192
233
 
193
234
  # Find all existing wrapper installations
@@ -257,7 +298,15 @@ cleanup_old_wrappers() {
257
298
  fi
258
299
 
259
300
  echo ""
260
- read -p "Would you like to clean up old installations? (y/n): " cleanup_choice
301
+
302
+ local cleanup_choice="n"
303
+ if [ "$INTERACTIVE" = true ]; then
304
+ read -p "Would you like to clean up old installations? (y/n): " cleanup_choice
305
+ else
306
+ # In non-interactive mode, auto-clean old installations
307
+ cleanup_choice="y"
308
+ echo "ℹ️ Non-interactive mode: auto-cleaning old installations..."
309
+ fi
261
310
 
262
311
  if [[ "$cleanup_choice" == "y" || "$cleanup_choice" == "Y" ]]; then
263
312
  echo ""
@@ -800,10 +849,15 @@ check_claude_installation() {
800
849
  echo "2. Install Claude Code from: https://www.anthropic.com/claude-code"
801
850
  echo "3. Continue anyway (wrappers will be created but won't work until claude is available)"
802
851
  echo ""
803
- read -p "Continue with installation? (y/n): " continue_choice
804
- if [[ "$continue_choice" != "y" && "$continue_choice" != "Y" ]]; then
805
- echo "Installation cancelled."
806
- exit 1
852
+
853
+ if [ "$INTERACTIVE" = true ]; then
854
+ read -p "Continue with installation? (y/n): " continue_choice
855
+ if [[ "$continue_choice" != "y" && "$continue_choice" != "Y" ]]; then
856
+ echo "Installation cancelled."
857
+ exit 1
858
+ fi
859
+ else
860
+ echo "ℹ️ Non-interactive mode: continuing anyway..."
807
861
  fi
808
862
  return 1
809
863
  fi
@@ -833,47 +887,66 @@ main() {
833
887
  if [ -f "$USER_BIN_DIR/claude-glm" ] || [ -f "$USER_BIN_DIR/claude-glm-fast" ]; then
834
888
  echo ""
835
889
  echo "✅ Existing installation detected!"
836
- echo "1) Update API key only"
837
- echo "2) Reinstall everything"
838
- echo "3) Cancel"
839
- read -p "Choice (1-3): " update_choice
840
890
 
841
- case "$update_choice" in
842
- 1)
843
- read -p "Enter your Z.AI API key: " input_key
844
- if [ -n "$input_key" ]; then
845
- ZAI_API_KEY="$input_key"
846
- create_claude_glm_wrapper
847
- create_claude_glm_46_wrapper
848
- create_claude_glm_45_wrapper
849
- create_claude_glm_fast_wrapper
850
- echo "✅ API key updated!"
891
+ if [ "$REINSTALL" = true ]; then
892
+ echo "ℹ️ Reinstalling (--reinstall flag or non-interactive mode)..."
893
+ elif [ "$INTERACTIVE" = true ]; then
894
+ echo "1) Update API key only"
895
+ echo "2) Reinstall everything"
896
+ echo "3) Cancel"
897
+ read -p "Choice (1-3): " update_choice
898
+
899
+ case "$update_choice" in
900
+ 1)
901
+ read -p "Enter your Z.AI API key: " input_key
902
+ if [ -n "$input_key" ]; then
903
+ ZAI_API_KEY="$input_key"
904
+ create_claude_glm_wrapper
905
+ create_claude_glm_46_wrapper
906
+ create_claude_glm_45_wrapper
907
+ create_claude_glm_fast_wrapper
908
+ echo "✅ API key updated!"
909
+ exit 0
910
+ fi
911
+ ;;
912
+ 2)
913
+ echo "Reinstalling..."
914
+ ;;
915
+ *)
851
916
  exit 0
852
- fi
853
- ;;
854
- 2)
855
- echo "Reinstalling..."
856
- ;;
857
- *)
858
- exit 0
859
- ;;
860
- esac
917
+ ;;
918
+ esac
919
+ else
920
+ echo "ℹ️ Non-interactive mode: reinstalling..."
921
+ fi
861
922
  fi
862
923
 
863
- # Get API key
864
- echo ""
865
- echo "Enter your Z.AI API key (from https://z.ai/manage-apikey/apikey-list)"
866
- read -p "API Key: " input_key
867
-
868
- if [ -n "$input_key" ]; then
869
- ZAI_API_KEY="$input_key"
870
- echo " API key received (${#input_key} characters)"
924
+ # Get API key (from argument, environment, or prompt)
925
+ if [ -n "$API_KEY_ARG" ]; then
926
+ ZAI_API_KEY="$API_KEY_ARG"
927
+ echo "✅ API key provided via argument (${#ZAI_API_KEY} characters)"
928
+ elif [ -n "${ZAI_API_KEY_ENV:-}" ]; then
929
+ ZAI_API_KEY="$ZAI_API_KEY_ENV"
930
+ echo "✅ API key provided via environment (${#ZAI_API_KEY} characters)"
931
+ elif [ "$INTERACTIVE" = true ]; then
932
+ echo ""
933
+ echo "Enter your Z.AI API key (from https://z.ai/manage-apikey/apikey-list)"
934
+ read -p "API Key: " input_key
935
+
936
+ if [ -n "$input_key" ]; then
937
+ ZAI_API_KEY="$input_key"
938
+ echo "✅ API key received (${#input_key} characters)"
939
+ else
940
+ echo "⚠️ No API key provided. Add it manually later to:"
941
+ echo " $USER_BIN_DIR/claude-glm"
942
+ echo " $USER_BIN_DIR/claude-glm-4.6"
943
+ echo " $USER_BIN_DIR/claude-glm-4.5"
944
+ echo " $USER_BIN_DIR/claude-glm-fast"
945
+ fi
871
946
  else
872
- echo "⚠️ No API key provided. Add it manually later to:"
873
- echo " $USER_BIN_DIR/claude-glm"
874
- echo " $USER_BIN_DIR/claude-glm-4.6"
875
- echo " $USER_BIN_DIR/claude-glm-4.5"
876
- echo " $USER_BIN_DIR/claude-glm-fast"
947
+ echo "⚠️ Non-interactive mode: No API key provided."
948
+ echo " Use --api-key=YOUR_KEY or set ZAI_API_KEY_ENV environment variable."
949
+ echo " Or add it manually later to the wrapper scripts."
877
950
  fi
878
951
 
879
952
  # Create wrappers
@@ -884,17 +957,26 @@ main() {
884
957
  create_shell_aliases
885
958
 
886
959
  # Ask about ccx installation
887
- echo ""
888
- echo "📦 Multi-Provider Proxy (ccx)"
889
- echo "================================"
890
- echo "ccx allows you to switch between multiple AI providers in a single session:"
891
- echo " OpenAI (GPT-4, GPT-4o, etc.)"
892
- echo " OpenRouter (access to many models)"
893
- echo " • Google Gemini"
894
- echo " Z.AI GLM models"
895
- echo " • Anthropic Claude"
896
- echo ""
897
- read -p "Install ccx? (Y/n): " install_ccx_choice
960
+ local install_ccx_choice="Y"
961
+
962
+ if [ "$SKIP_CCX" = true ]; then
963
+ install_ccx_choice="n"
964
+ echo "ℹ️ Skipping ccx installation (--skip-ccx flag)"
965
+ elif [ "$INTERACTIVE" = true ]; then
966
+ echo ""
967
+ echo "📦 Multi-Provider Proxy (ccx)"
968
+ echo "================================"
969
+ echo "ccx allows you to switch between multiple AI providers in a single session:"
970
+ echo " OpenAI (GPT-4, GPT-4o, etc.)"
971
+ echo " • OpenRouter (access to many models)"
972
+ echo " • Google Gemini"
973
+ echo " • Z.AI GLM models"
974
+ echo " • Anthropic Claude"
975
+ echo ""
976
+ read -p "Install ccx? (Y/n): " install_ccx_choice
977
+ else
978
+ echo "ℹ️ Non-interactive mode: installing ccx by default (use --skip-ccx to skip)"
979
+ fi
898
980
 
899
981
  if [ "$install_ccx_choice" != "n" ] && [ "$install_ccx_choice" != "N" ]; then
900
982
  install_ccx
@@ -970,8 +1052,10 @@ handle_error() {
970
1052
  # Give user time to read any final messages before stopping
971
1053
  echo ""
972
1054
  echo "Installation terminated due to error."
973
- echo "Press Enter to finish (window will remain open)..."
974
- read
1055
+ if [ "$INTERACTIVE" = true ]; then
1056
+ echo "Press Enter to finish (window will remain open)..."
1057
+ read
1058
+ fi
975
1059
  # Return to stop script execution without closing terminal
976
1060
  return
977
1061
  }
@@ -996,10 +1080,12 @@ if [ "$TEST_ERROR" = true ]; then
996
1080
  echo "✅ Test complete. If a browser window opened, error reporting is working!"
997
1081
  echo ""
998
1082
  echo "To run normal installation, use:"
999
- echo " curl -fsSL https://raw.githubusercontent.com/JoeInnsp23/claude-glm-wrapper/main/install.sh | bash"
1083
+ echo " curl -fsSL https://raw.githubusercontent.com/MohMaya/claude-glm-wrapper/main/install.sh | bash"
1000
1084
  echo ""
1001
- echo "Press Enter to finish (window will remain open)..."
1002
- read
1085
+ if [ "$INTERACTIVE" = true ]; then
1086
+ echo "Press Enter to finish (window will remain open)..."
1087
+ read
1088
+ fi
1003
1089
  # Script ends naturally here - terminal stays open
1004
1090
  exit 0
1005
1091
  fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-glm-alt-installer",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Cross-platform installer for Claude Code with Z.AI GLM models and multi-provider proxy. Run with: npx claude-glm-alt-installer",
5
5
  "keywords": [
6
6
  "claude",