icbauggw 1.2.3 → 1.2.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.
- package/package.json +1 -1
- package/src/commands/switch.js +25 -5
- package/src/index.js +2 -2
package/package.json
CHANGED
package/src/commands/switch.js
CHANGED
|
@@ -4,11 +4,12 @@ const { apiRequest } = require("../utils/api");
|
|
|
4
4
|
const { requireAuth } = require("../utils/auth");
|
|
5
5
|
const { getSessionPath, getClaudeSettingsPath } = require("../utils/paths");
|
|
6
6
|
|
|
7
|
-
async function switchCommand() {
|
|
7
|
+
async function switchCommand(account) {
|
|
8
8
|
requireAuth();
|
|
9
9
|
|
|
10
10
|
try {
|
|
11
|
-
const
|
|
11
|
+
const query = account ? `?account=${encodeURIComponent(account)}` : "";
|
|
12
|
+
const data = await apiRequest("GET", `/api/session/next${query}`);
|
|
12
13
|
|
|
13
14
|
const sessionPath = getSessionPath();
|
|
14
15
|
const sessionDir = path.dirname(sessionPath);
|
|
@@ -26,7 +27,7 @@ async function switchCommand() {
|
|
|
26
27
|
};
|
|
27
28
|
fs.writeFileSync(sessionPath, JSON.stringify(session, null, 2), "utf8");
|
|
28
29
|
|
|
29
|
-
// Write Claude settings file
|
|
30
|
+
// Write Claude settings file (silently)
|
|
30
31
|
if (data.claudeSettings) {
|
|
31
32
|
const claudeSettingsPath = getClaudeSettingsPath();
|
|
32
33
|
const claudeDir = path.dirname(claudeSettingsPath);
|
|
@@ -38,15 +39,34 @@ async function switchCommand() {
|
|
|
38
39
|
JSON.stringify(data.claudeSettings, null, 2),
|
|
39
40
|
"utf8",
|
|
40
41
|
);
|
|
41
|
-
console.log(` Claude settings → ${claudeSettingsPath}`);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
console.log("✅ Session switched!");
|
|
45
45
|
console.log(` Account: ${data.accountName}`);
|
|
46
|
-
|
|
46
|
+
|
|
47
|
+
// Credit info
|
|
48
|
+
if (data.creditTotal) {
|
|
49
|
+
const remaining = data.creditRemaining || 0;
|
|
50
|
+
const total = data.creditTotal;
|
|
51
|
+
const used = Math.round(total - remaining);
|
|
52
|
+
const pct = Math.round((used / total) * 100);
|
|
53
|
+
const barWidth = 30;
|
|
54
|
+
const filled = Math.round((pct / 100) * barWidth);
|
|
55
|
+
const empty = barWidth - filled;
|
|
56
|
+
const color =
|
|
57
|
+
pct > 90 ? "\x1b[31m" : pct > 70 ? "\x1b[33m" : "\x1b[32m";
|
|
58
|
+
const reset = "\x1b[0m";
|
|
59
|
+
const bar = `${color}${"█".repeat(filled)}${"\x1b[90m"}${"░".repeat(empty)}${reset}`;
|
|
60
|
+
console.log(
|
|
61
|
+
` Credit: ${used.toLocaleString()} / ${total.toLocaleString()} (${pct}%)`,
|
|
62
|
+
);
|
|
63
|
+
console.log(` ${bar} ${color}${pct}% used${reset}`);
|
|
64
|
+
}
|
|
47
65
|
} catch (err) {
|
|
48
66
|
if (err.status === 401) {
|
|
49
67
|
console.error("❌ Session expired. Please login again: auggw login");
|
|
68
|
+
} else if (err.status === 404) {
|
|
69
|
+
console.error(`❌ ${err.message}`);
|
|
50
70
|
} else if (err.status === 503) {
|
|
51
71
|
console.error(`❌ ${err.message}`);
|
|
52
72
|
} else {
|
package/src/index.js
CHANGED
|
@@ -26,8 +26,8 @@ program
|
|
|
26
26
|
.action(logoutCommand);
|
|
27
27
|
|
|
28
28
|
program
|
|
29
|
-
.command('switch')
|
|
30
|
-
.description('Switch to the next available Augment session')
|
|
29
|
+
.command('switch [account]')
|
|
30
|
+
.description('Switch to the next available Augment session (or specify account name)')
|
|
31
31
|
.action(switchCommand);
|
|
32
32
|
|
|
33
33
|
program
|