@adithya-13/cc-switch 1.0.4 → 1.0.5

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/cclaude.js +18 -10
  2. package/package.json +1 -1
package/bin/cclaude.js CHANGED
@@ -56,11 +56,13 @@ function notifyRateLimit(current, fallbacks) {
56
56
  const settings = readSettings();
57
57
  const current = getCurrentProvider(settings);
58
58
 
59
+ // OAuth mode (pro/claude) sends rate limit to stdout, API providers to stderr
60
+ const isOAuthMode = current === "pro" || current === "claude";
61
+
59
62
  const child = spawn("claude", process.argv.slice(2), {
60
- stdio: ["inherit", "pipe", "pipe"], // intercept both stdout and stderr
63
+ stdio: ["inherit", isOAuthMode ? "pipe" : "inherit", "pipe"], // always pipe stderr
61
64
  });
62
65
 
63
- let combinedBuffer = "";
64
66
  let notified = false;
65
67
 
66
68
  function checkRateLimit(text) {
@@ -73,18 +75,24 @@ function checkRateLimit(text) {
73
75
  }
74
76
  }
75
77
 
76
- child.stdout.on("data", (data) => {
77
- const text = data.toString();
78
- combinedBuffer += text;
79
- process.stdout.write(data); // forward to user
80
- checkRateLimit(combinedBuffer);
81
- });
78
+ // Only capture stdout for OAuth mode (pro/claude)
79
+ if (isOAuthMode) {
80
+ let buffer = "";
81
+ child.stdout.on("data", (data) => {
82
+ const text = data.toString();
83
+ buffer += text;
84
+ process.stdout.write(data); // forward to user
85
+ checkRateLimit(buffer);
86
+ });
87
+ }
82
88
 
89
+ // Always capture stderr for API providers' rate limit errors
90
+ let stderrBuffer = "";
83
91
  child.stderr.on("data", (data) => {
84
92
  const text = data.toString();
85
- combinedBuffer += text;
93
+ stderrBuffer += text;
86
94
  process.stderr.write(data); // forward to user
87
- checkRateLimit(combinedBuffer);
95
+ checkRateLimit(stderrBuffer);
88
96
  });
89
97
 
90
98
  child.on("exit", (code) => process.exit(code ?? 0));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adithya-13/cc-switch",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Switch Claude Code between providers (Claude Pro, z.ai, Kimi, OpenRouter, DeepSeek, and more)",
5
5
  "keywords": [
6
6
  "claude",