augteam 1.1.2 → 1.1.4
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/status.js +5 -4
- package/src/index.js +51 -50
- package/src/utils/api.js +3 -1
- package/src/utils/auth.js +2 -1
- package/src/utils/paths.js +9 -2
package/package.json
CHANGED
package/src/commands/status.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { apiRequest } = require("../utils/api");
|
|
2
2
|
const { requireAuth } = require("../utils/auth");
|
|
3
|
+
const { getCliName } = require("../utils/paths");
|
|
3
4
|
|
|
4
5
|
async function statusCommand() {
|
|
5
6
|
requireAuth();
|
|
@@ -8,7 +9,7 @@ async function statusCommand() {
|
|
|
8
9
|
const data = await apiRequest("GET", "/api/session/status");
|
|
9
10
|
|
|
10
11
|
if (!data.current) {
|
|
11
|
-
console.log(
|
|
12
|
+
console.log(`ℹ️ No active session. Run: ${getCliName()} switch`);
|
|
12
13
|
console.log();
|
|
13
14
|
} else {
|
|
14
15
|
console.log("📋 Current Account");
|
|
@@ -20,7 +21,7 @@ async function statusCommand() {
|
|
|
20
21
|
if (data.current.creditTotal) {
|
|
21
22
|
const remaining = data.current.creditRemaining || 0;
|
|
22
23
|
const total = data.current.creditTotal;
|
|
23
|
-
const used = total - remaining;
|
|
24
|
+
const used = Math.round(total - remaining);
|
|
24
25
|
const pct = Math.round((used / total) * 100);
|
|
25
26
|
const barWidth = 30;
|
|
26
27
|
const filled = Math.round((pct / 100) * barWidth);
|
|
@@ -29,7 +30,7 @@ async function statusCommand() {
|
|
|
29
30
|
const reset = "\x1b[0m";
|
|
30
31
|
const bar = `${color}${"█".repeat(filled)}${"\x1b[90m"}${"░".repeat(empty)}${reset}`;
|
|
31
32
|
console.log(
|
|
32
|
-
` Credit: ${
|
|
33
|
+
` Credit: ${used.toLocaleString()} / ${total.toLocaleString()} (${pct}%)`,
|
|
33
34
|
);
|
|
34
35
|
console.log(
|
|
35
36
|
` ${bar} ${color}${pct}% used${reset}`,
|
|
@@ -46,7 +47,7 @@ async function statusCommand() {
|
|
|
46
47
|
console.log(` Total: ${data.pool.total} accounts`);
|
|
47
48
|
} catch (err) {
|
|
48
49
|
if (err.status === 401) {
|
|
49
|
-
console.error(
|
|
50
|
+
console.error(`❌ Session expired. Please login again: ${getCliName()} login`);
|
|
50
51
|
} else {
|
|
51
52
|
console.error(`❌ Error: ${err.message}`);
|
|
52
53
|
}
|
package/src/index.js
CHANGED
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
program
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
.
|
|
47
|
-
.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
const path = require("path");
|
|
2
|
+
require("dotenv").config({ path: path.join(__dirname, "..", ".env"), quiet: true });
|
|
3
|
+
const { Command } = require("commander");
|
|
4
|
+
const loginCommand = require("./commands/login");
|
|
5
|
+
const logoutCommand = require("./commands/logout");
|
|
6
|
+
const switchCommand = require("./commands/switch");
|
|
7
|
+
const statusCommand = require("./commands/status");
|
|
8
|
+
const updateCommand = require("./commands/update");
|
|
9
|
+
const fetchCommand = require("./commands/fetch");
|
|
10
|
+
const { checkUpdate } = require("./utils/update");
|
|
11
|
+
const pkg = require("../package.json");
|
|
12
|
+
|
|
13
|
+
const program = new Command();
|
|
14
|
+
|
|
15
|
+
program
|
|
16
|
+
.name(Object.keys(pkg.bin)[0] || "auggw")
|
|
17
|
+
.description("CLI tool for rotating Augment session accounts")
|
|
18
|
+
.version(pkg.version);
|
|
19
|
+
|
|
20
|
+
program
|
|
21
|
+
.command("login")
|
|
22
|
+
.description("Authenticate with the session rotator backend")
|
|
23
|
+
.action(loginCommand);
|
|
24
|
+
|
|
25
|
+
program
|
|
26
|
+
.command("logout")
|
|
27
|
+
.description("Remove saved token and log out")
|
|
28
|
+
.action(logoutCommand);
|
|
29
|
+
|
|
30
|
+
program
|
|
31
|
+
.command("switch")
|
|
32
|
+
.description("Switch to the next available Augment session")
|
|
33
|
+
.action(switchCommand);
|
|
34
|
+
|
|
35
|
+
program
|
|
36
|
+
.command("status")
|
|
37
|
+
.description("View current account and pool status")
|
|
38
|
+
.action(statusCommand);
|
|
39
|
+
|
|
40
|
+
program
|
|
41
|
+
.command("update")
|
|
42
|
+
.description("Update CLI to the latest version")
|
|
43
|
+
.action(updateCommand);
|
|
44
|
+
|
|
45
|
+
program
|
|
46
|
+
.command("fetch")
|
|
47
|
+
.description("Fetch resources from server")
|
|
48
|
+
.option("--prompts", "Fetch commands & skills to ~/.augment and/or ~/.claude")
|
|
49
|
+
.action(fetchCommand);
|
|
50
|
+
|
|
51
|
+
program.parseAsync().then(() => checkUpdate());
|
package/src/utils/api.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
const os = require("os");
|
|
2
2
|
const { loadToken } = require("./token");
|
|
3
|
+
const { getCliName } = require("./paths");
|
|
3
4
|
|
|
4
5
|
const DEFAULT_API_URL = "https://augteam.quangit.site";
|
|
5
6
|
// const DEFAULT_API_URL = "http://localhost:3000";
|
|
6
7
|
|
|
7
8
|
function getBaseURL() {
|
|
8
|
-
|
|
9
|
+
const envKey = `${getCliName()}_API_URL`;
|
|
10
|
+
return process.env[envKey] || DEFAULT_API_URL;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
function getLocalIP() {
|
package/src/utils/auth.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
const { loadToken } = require("./token");
|
|
2
|
+
const { getCliName } = require("./paths");
|
|
2
3
|
|
|
3
4
|
function requireAuth() {
|
|
4
5
|
const token = loadToken();
|
|
5
6
|
if (!token) {
|
|
6
|
-
console.error(
|
|
7
|
+
console.error(`❌ Please login first: ${getCliName()} login`);
|
|
7
8
|
process.exit(1);
|
|
8
9
|
}
|
|
9
10
|
}
|
package/src/utils/paths.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
const os = require("os");
|
|
2
2
|
const path = require("path");
|
|
3
3
|
|
|
4
|
+
const pkg = require("../../package.json");
|
|
5
|
+
const CLI_NAME = Object.keys(pkg.bin || {})[0] || "auggw";
|
|
6
|
+
|
|
4
7
|
function getTokenPath() {
|
|
5
|
-
return path.join(os.homedir(),
|
|
8
|
+
return path.join(os.homedir(), `.${CLI_NAME}`, "token");
|
|
6
9
|
}
|
|
7
10
|
|
|
8
11
|
function getSessionPath() {
|
|
9
12
|
return path.join(os.homedir(), ".augment", "session.json");
|
|
10
13
|
}
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
function getCliName() {
|
|
16
|
+
return CLI_NAME;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = { getTokenPath, getSessionPath, getCliName };
|