claude-glm-alt-installer 2.0.0 → 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 (4) hide show
  1. package/README.md +67 -0
  2. package/bin/cli.js +15 -6
  3. package/install.sh +154 -68
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Claude-GLM Wrapper
2
2
 
3
+ > **📢 Community Fork Notice**
4
+ >
5
+ > This is an actively maintained community fork of the original [claude-glm-wrapper](https://github.com/JoeInnsp23/claude-glm-wrapper).
6
+ > The upstream repository is currently unmaintained. This fork includes bug fixes, new features, and ongoing support.
7
+ >
8
+ > Install via: `npx claude-glm-alt-installer`
9
+
10
+ ---
11
+
3
12
  Use [Z.AI's GLM models](https://z.ai) with [Claude Code](https://www.anthropic.com/claude-code) — **without losing your existing Claude setup!**
4
13
 
5
14
  Switch freely between multiple AI providers: GLM, OpenAI, Gemini, OpenRouter, and Anthropic Claude.
@@ -23,6 +32,7 @@ npx claude-glm-alt-installer
23
32
  ```
24
33
 
25
34
  Then activate (platform-specific):
35
+
26
36
  ```bash
27
37
  # macOS / Linux:
28
38
  source ~/.zshrc # or ~/.bashrc
@@ -34,6 +44,7 @@ source ~/.zshrc # or ~/.bashrc
34
44
  ### Start Using GLM Models
35
45
 
36
46
  **All Platforms:**
47
+
37
48
  ```bash
38
49
  ccg # Claude Code with GLM-4.7 (latest)
39
50
  ccg46 # Claude Code with GLM-4.6
@@ -95,6 +106,7 @@ npx claude-glm-alt-installer
95
106
  ```
96
107
 
97
108
  The installer will:
109
+
98
110
  - Auto-detect your operating system
99
111
  - Check if Claude Code is installed
100
112
  - Ask for your Z.AI API key
@@ -117,12 +129,14 @@ source ~/.zshrc # or ~/.bashrc
117
129
  <summary>macOS / Linux</summary>
118
130
 
119
131
  **One-Line Install:**
132
+
120
133
  ```bash
121
134
  bash <(curl -fsSL https://raw.githubusercontent.com/MohMaya/claude-glm-wrapper/main/install.sh)
122
135
  source ~/.zshrc # or ~/.bashrc
123
136
  ```
124
137
 
125
138
  **Clone and Install:**
139
+
126
140
  ```bash
127
141
  git clone https://github.com/MohMaya/claude-glm-wrapper.git
128
142
  cd claude-glm-wrapper
@@ -136,12 +150,14 @@ source ~/.zshrc
136
150
  <summary>Windows (PowerShell)</summary>
137
151
 
138
152
  **One-Line Install:**
153
+
139
154
  ```powershell
140
155
  iwr -useb https://raw.githubusercontent.com/MohMaya/claude-glm-wrapper/main/install.ps1 | iex
141
156
  . $PROFILE
142
157
  ```
143
158
 
144
159
  **Clone and Install:**
160
+
145
161
  ```powershell
146
162
  git clone https://github.com/MohMaya/claude-glm-wrapper.git
147
163
  cd claude-glm-wrapper
@@ -150,6 +166,7 @@ cd claude-glm-wrapper
150
166
  ```
151
167
 
152
168
  **Note:** If you get an execution policy error, run:
169
+
153
170
  ```powershell
154
171
  Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
155
172
  ```
@@ -176,6 +193,7 @@ The installer creates these commands and aliases:
176
193
  **🆕 New: ccx Multi-Provider Proxy**
177
194
 
178
195
  The `ccx` command starts a local proxy that lets you switch between multiple AI providers in a single session:
196
+
179
197
  - **OpenAI**: GPT-4o, GPT-4o-mini, and more
180
198
  - **OpenRouter**: Access to hundreds of models
181
199
  - **Google Gemini**: Gemini 1.5 Pro and Flash
@@ -187,6 +205,7 @@ Switch models mid-session using `/model <provider>:<model-name>`. Perfect for co
187
205
  ### How It Works
188
206
 
189
207
  Each command starts a **separate Claude Code session** with different configurations:
208
+
190
209
  - `ccg`, `ccg45`, and `ccf` use Z.AI's API with your Z.AI key
191
210
  - `cc` uses Anthropic's API with your Anthropic key (default Claude setup)
192
211
  - Your configurations **never conflict** — they're stored in separate directories
@@ -194,36 +213,42 @@ Each command starts a **separate Claude Code session** with different configurat
194
213
  ### Basic Examples
195
214
 
196
215
  **Start a coding session with the latest GLM:**
216
+
197
217
  ```bash
198
218
  ccg
199
219
  # Opens Claude Code using GLM-4.7
200
220
  ```
201
221
 
202
222
  **Use GLM-4.6:**
223
+
203
224
  ```bash
204
225
  ccg46
205
226
  # Opens Claude Code using GLM-4.6
206
227
  ```
207
228
 
208
229
  **Use GLM-4.5:**
230
+
209
231
  ```bash
210
232
  ccg45
211
233
  # Opens Claude Code using GLM-4.5
212
234
  ```
213
235
 
214
236
  **Need faster responses? Use the fast model:**
237
+
215
238
  ```bash
216
239
  ccf
217
240
  # Opens Claude Code using GLM-4.5-Air
218
241
  ```
219
242
 
220
243
  **Use regular Claude:**
244
+
221
245
  ```bash
222
246
  cc
223
247
  # Opens Claude Code with Anthropic models (your default setup)
224
248
  ```
225
249
 
226
250
  **Pass arguments like normal:**
251
+
227
252
  ```bash
228
253
  ccg --help
229
254
  ccg "refactor this function"
@@ -233,6 +258,7 @@ ccf "quick question about Python"
233
258
  ## Common Workflows
234
259
 
235
260
  ### Workflow 1: Testing with GLM, Production with Claude
261
+
236
262
  ```bash
237
263
  # Develop and test with cost-effective GLM-4.7
238
264
  ccg
@@ -245,6 +271,7 @@ cc
245
271
  ```
246
272
 
247
273
  ### Workflow 2: Quick Questions with Fast Model
274
+
248
275
  ```bash
249
276
  # Quick syntax questions
250
277
  ccf "how do I use async/await in Python?"
@@ -255,6 +282,7 @@ ccg
255
282
  ```
256
283
 
257
284
  ### Workflow 3: Multiple Projects
285
+
258
286
  ```bash
259
287
  # Project 1: Use GLM to save costs
260
288
  cd ~/project1
@@ -337,6 +365,7 @@ Use Claude Code's built-in `/model` command with provider prefixes:
337
365
  ### ccx Workflows
338
366
 
339
367
  **Workflow 1: Compare Model Responses**
368
+
340
369
  ```bash
341
370
  ccx
342
371
  # Ask a question
@@ -347,6 +376,7 @@ ccx
347
376
  ```
348
377
 
349
378
  **Workflow 2: Cost Optimization**
379
+
350
380
  ```bash
351
381
  ccx
352
382
  # Start with a fast, cheap model for exploration
@@ -357,6 +387,7 @@ ccx
357
387
  ```
358
388
 
359
389
  **Workflow 3: Leverage Model Strengths**
390
+
360
391
  ```bash
361
392
  ccx
362
393
  # Use GPT-4 for coding
@@ -395,6 +426,7 @@ ccx
395
426
  Each wrapper uses its own configuration directory to prevent conflicts:
396
427
 
397
428
  **macOS / Linux:**
429
+
398
430
  | Command | Config Directory | Purpose |
399
431
  |---------|-----------------|---------|
400
432
  | `claude-glm` | `~/.claude-glm/` | GLM-4.7 settings and history |
@@ -404,6 +436,7 @@ Each wrapper uses its own configuration directory to prevent conflicts:
404
436
  | `claude` | `~/.claude/` (default) | Your original Claude setup |
405
437
 
406
438
  **Windows:**
439
+
407
440
  | Command | Config Directory | Purpose |
408
441
  |---------|-----------------|---------|
409
442
  | `claude-glm` | `%USERPROFILE%\.claude-glm\` | GLM-4.7 settings and history |
@@ -413,6 +446,7 @@ Each wrapper uses its own configuration directory to prevent conflicts:
413
446
  | `claude` | `%USERPROFILE%\.claude\` (default) | Your original Claude setup |
414
447
 
415
448
  **This means:**
449
+
416
450
  - ✅ Your original Claude settings are **never touched**
417
451
  - ✅ Chat histories stay separate for each model
418
452
  - ✅ API keys are isolated — no mixing!
@@ -420,12 +454,14 @@ Each wrapper uses its own configuration directory to prevent conflicts:
420
454
  ### Wrapper Scripts Location
421
455
 
422
456
  **macOS / Linux:** `~/.local/bin/`
457
+
423
458
  - `claude-glm` (GLM-4.7)
424
459
  - `claude-glm-4.6` (GLM-4.6)
425
460
  - `claude-glm-4.5` (GLM-4.5)
426
461
  - `claude-glm-fast` (GLM-4.5-Air)
427
462
 
428
463
  **Windows:** `%USERPROFILE%\.local\bin\`
464
+
429
465
  - `claude-glm.ps1` (GLM-4.7)
430
466
  - `claude-glm-4.6.ps1` (GLM-4.6)
431
467
  - `claude-glm-4.5.ps1` (GLM-4.5)
@@ -438,12 +474,14 @@ These are just tiny wrapper scripts (bash or PowerShell) that set the right envi
438
474
  ### macOS / Linux
439
475
 
440
476
  **Option 1: Use the Installer**
477
+
441
478
  ```bash
442
479
  cd claude-glm-wrapper && bash install.sh
443
480
  # Choose option "1) Update API key only"
444
481
  ```
445
482
 
446
483
  **Option 2: Edit Manually**
484
+
447
485
  ```bash
448
486
  nano ~/.local/bin/claude-glm
449
487
  nano ~/.local/bin/claude-glm-4.6
@@ -455,6 +493,7 @@ nano ~/.local/bin/claude-glm-fast
455
493
  ### Windows (PowerShell)
456
494
 
457
495
  **Option 1: Use the Installer**
496
+
458
497
  ```powershell
459
498
  cd claude-glm-wrapper
460
499
  .\install.ps1
@@ -462,6 +501,7 @@ cd claude-glm-wrapper
462
501
  ```
463
502
 
464
503
  **Option 2: Edit Manually**
504
+
465
505
  ```powershell
466
506
  notepad "$env:USERPROFILE\.local\bin\claude-glm.ps1"
467
507
  notepad "$env:USERPROFILE\.local\bin\claude-glm-4.6.ps1"
@@ -490,6 +530,7 @@ Claude Code reads these variables and uses them instead of the defaults. Simple!
490
530
  **Problem**: Claude Code isn't installed or not in your PATH.
491
531
 
492
532
  **Solutions**:
533
+
493
534
  1. Install Claude Code from [anthropic.com/claude-code](https://www.anthropic.com/claude-code)
494
535
  2. Or add Claude to your PATH if it's installed elsewhere
495
536
 
@@ -500,6 +541,7 @@ Claude Code reads these variables and uses them instead of the defaults. Simple!
500
541
  **Problem**: You didn't source your shell config after installation.
501
542
 
502
543
  **Solution**: Run the source command the installer showed you:
544
+
503
545
  ```bash
504
546
  source ~/.zshrc # or ~/.bashrc
505
547
  ```
@@ -511,11 +553,13 @@ source ~/.zshrc # or ~/.bashrc
511
553
  **Problem**: API key issues.
512
554
 
513
555
  **Solutions for ccg/ccf/ccg45**:
556
+
514
557
  1. **Check your key**: Visit [z.ai/manage-apikey/apikey-list](https://z.ai/manage-apikey/apikey-list)
515
558
  2. **Verify credits**: Make sure your Z.AI account has available credits
516
559
  3. **Update the key**: Run `bash install.sh` and choose "Update API key only"
517
560
 
518
561
  **Solutions for ccx**:
562
+
519
563
  1. **Check your .env file**: Edit `~/.claude-proxy/.env`
520
564
  2. **Verify keys are set**: Make sure the API keys for the providers you're using are filled in
521
565
  3. **No empty values**: If you're not using a provider, either leave it blank or remove the line
@@ -526,6 +570,7 @@ source ~/.zshrc # or ~/.bashrc
526
570
  **Problem**: Proxy fails to start or times out.
527
571
 
528
572
  **Solutions**:
573
+
529
574
  1. **Check logs**: Look at `/tmp/claude-proxy.log` (Unix) or `%TEMP%\claude-proxy.log` (Windows)
530
575
  2. **Port in use**: Another process might be using port 17870. Set `CLAUDE_PROXY_PORT=17871` in .env
531
576
  3. **Missing dependencies**: Run `npm install -g tsx` to ensure TypeScript runner is available
@@ -536,6 +581,7 @@ source ~/.zshrc # or ~/.bashrc
536
581
  **Problem**: `/model` command doesn't seem to work.
537
582
 
538
583
  **Solutions**:
584
+
539
585
  1. **Check provider prefix**: Use format `/model provider:model-name` (e.g., `/model openai:gpt-4o`)
540
586
  2. **Verify API key**: Make sure the provider's API key is set in `~/.claude-proxy/.env`
541
587
  3. **Check proxy logs**: Look for errors in `/tmp/claude-proxy.log`
@@ -545,6 +591,7 @@ source ~/.zshrc # or ~/.bashrc
545
591
  **Problem**: Using `ccg` but it's using the wrong API.
546
592
 
547
593
  **Solution**: Each command is independent. Make sure you:
594
+
548
595
  - Exit any running Claude Code session
549
596
  - Start fresh with the command you want (`ccg`, `ccg45`, `ccf`, or `cc`)
550
597
 
@@ -555,6 +602,7 @@ source ~/.zshrc # or ~/.bashrc
555
602
  **Problem**: PowerShell execution policy prevents running scripts.
556
603
 
557
604
  **Solution**:
605
+
558
606
  ```powershell
559
607
  Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
560
608
  ```
@@ -564,6 +612,7 @@ Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
564
612
  **Problem**: PowerShell profile wasn't reloaded after installation.
565
613
 
566
614
  **Solutions**:
615
+
567
616
  1. Reload profile: `. $PROFILE`
568
617
  2. Or restart PowerShell
569
618
  3. Or run the full command: `claude-glm`
@@ -585,6 +634,7 @@ Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
585
634
  ### macOS / Linux
586
635
 
587
636
  **Remove wrapper scripts:**
637
+
588
638
  ```bash
589
639
  rm ~/.local/bin/claude-glm
590
640
  rm ~/.local/bin/claude-glm-4.6
@@ -593,6 +643,7 @@ rm ~/.local/bin/claude-glm-fast
593
643
  ```
594
644
 
595
645
  **Remove config directories** (optional - deletes chat history):
646
+
596
647
  ```bash
597
648
  rm -rf ~/.claude-glm
598
649
  rm -rf ~/.claude-glm-46
@@ -601,6 +652,7 @@ rm -rf ~/.claude-glm-fast
601
652
  ```
602
653
 
603
654
  **Remove aliases** from `~/.zshrc` or `~/.bashrc`:
655
+
604
656
  ```bash
605
657
  # Delete these lines:
606
658
  # Claude Code Model Switcher Aliases
@@ -616,6 +668,7 @@ Then run: `source ~/.zshrc`
616
668
  ### Windows (PowerShell)
617
669
 
618
670
  **Remove wrapper scripts:**
671
+
619
672
  ```powershell
620
673
  Remove-Item "$env:USERPROFILE\.local\bin\claude-glm.ps1"
621
674
  Remove-Item "$env:USERPROFILE\.local\bin\claude-glm-4.6.ps1"
@@ -624,6 +677,7 @@ Remove-Item "$env:USERPROFILE\.local\bin\claude-glm-fast.ps1"
624
677
  ```
625
678
 
626
679
  **Remove config directories** (optional - deletes chat history):
680
+
627
681
  ```powershell
628
682
  Remove-Item -Recurse "$env:USERPROFILE\.claude-glm"
629
683
  Remove-Item -Recurse "$env:USERPROFILE\.claude-glm-46"
@@ -632,6 +686,7 @@ Remove-Item -Recurse "$env:USERPROFILE\.claude-glm-fast"
632
686
  ```
633
687
 
634
688
  **Remove aliases** from PowerShell profile:
689
+
635
690
  ```powershell
636
691
  notepad $PROFILE
637
692
  # Delete these lines:
@@ -648,18 +703,24 @@ Then reload: `. $PROFILE`
648
703
  ## FAQ
649
704
 
650
705
  ### Q: Will this affect my existing Claude Code setup?
706
+
651
707
  **A**: No! Your regular Claude Code setup is completely untouched. The wrappers use separate config directories.
652
708
 
653
709
  ### Q: Can I use both GLM and Claude in the same project?
710
+
654
711
  **A**: Yes! Just use `ccg` for GLM sessions and `cc` for Claude sessions. Each maintains its own chat history. Or use `ccx` to switch between providers in a single session.
655
712
 
656
713
  ### Q: Which should I use: ccx or dedicated wrappers (ccg/ccf)?
714
+
657
715
  **A**:
716
+
658
717
  - **Use ccx** if you want to switch between multiple providers (OpenAI, Gemini, OpenRouter, GLM, Anthropic) in the same session
659
718
  - **Use dedicated wrappers** if you want separate chat histories for different models/providers
660
719
 
661
720
  ### Q: Which model should I use?
721
+
662
722
  **A**:
723
+
663
724
  - Use **`ccx`** for: Maximum flexibility, model comparison, leveraging different model strengths
664
725
  - Use **`ccg` (GLM-4.7)** for: Latest model, complex coding, refactoring, detailed explanations
665
726
  - Use **`ccg46` (GLM-4.6)** for: Previous version, if you need consistency with older projects
@@ -668,22 +729,28 @@ Then reload: `. $PROFILE`
668
729
  - Use **`cc` (Claude)** for: Your regular Anthropic Claude setup
669
730
 
670
731
  ### Q: How do I switch models in ccx?
732
+
671
733
  **A**: Use the `/model` command with the format `<provider>:<model-name>`. For example:
734
+
672
735
  - `/model openai:gpt-4o`
673
736
  - `/model gemini:gemini-1.5-pro`
674
737
  - `/model glm:glm-4.7`
675
738
  - `/model glm:glm-4.6`
676
739
 
677
740
  ### Q: Is this secure?
741
+
678
742
  **A**: Yes! Your API keys are stored locally on your machine in wrapper scripts (bash or PowerShell, depending on your OS). Keep your scripts directory secure with appropriate permissions.
679
743
 
680
744
  ### Q: Does this work on Windows?
745
+
681
746
  **A**: Yes! Use the PowerShell installer (install.ps1). Windows, macOS, and Linux are all fully supported.
682
747
 
683
748
  ### Q: Can I use a different Z.AI model?
749
+
684
750
  **A**: Yes! Edit the wrapper scripts in `~/.local/bin/` and change the `ANTHROPIC_MODEL` variable to any model Z.AI supports.
685
751
 
686
752
  ### Q: What happens if I run out of Z.AI credits?
753
+
687
754
  **A**: The GLM commands will fail with an API error. Just switch to regular Claude using `cc` until you add more credits.
688
755
 
689
756
  ## Contributing
package/bin/cli.js CHANGED
@@ -1,9 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { spawn } = require('child_process');
4
- const path = require('path');
5
- const os = require('os');
6
- const fs = require('fs');
3
+ import { spawn } from 'child_process';
4
+ import path from 'path';
5
+ import os from 'os';
6
+ import fs from 'fs';
7
+ import tty from 'tty';
8
+ import { fileURLToPath } from 'url';
9
+
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = path.dirname(__filename);
7
12
 
8
13
  const platform = os.platform();
9
14
  const rootDir = path.join(__dirname, '..');
@@ -15,6 +20,9 @@ console.log(`Detected OS: ${platform}\n`);
15
20
  function runInstaller() {
16
21
  let command, args, scriptPath;
17
22
 
23
+ // Check if running in interactive mode (TTY available)
24
+ const isInteractive = tty.isatty(0);
25
+
18
26
  if (platform === 'win32') {
19
27
  // Windows - run PowerShell installer
20
28
  console.log('🪟 Running Windows PowerShell installer...\n');
@@ -51,9 +59,10 @@ function runInstaller() {
51
59
  process.exit(1);
52
60
  }
53
61
 
54
- // 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
55
64
  const installer = spawn(command, args, {
56
- stdio: 'inherit',
65
+ stdio: ['inherit', 'inherit', 'inherit'],
57
66
  cwd: rootDir
58
67
  });
59
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.0",
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",