icbauggw 1.0.3 → 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.
package/SETUP.md CHANGED
@@ -7,23 +7,23 @@
7
7
  ## Cài đặt
8
8
 
9
9
  ```bash
10
- npm install -g icbauggw
10
+ npm install -g auggw
11
11
  ```
12
12
 
13
13
  ## Đăng nhập
14
14
 
15
15
  ```bash
16
- icbauggw login
16
+ auggw login
17
17
  ```
18
18
 
19
- Nhập username và password được cấp. Token sẽ lưu tại `~/.icb-aug/token`.
19
+ Nhập username và password được cấp. Token sẽ lưu tại `~/gg/token`.
20
20
 
21
21
  ## Sử dụng
22
22
 
23
23
  ### Chuyển session
24
24
 
25
25
  ```bash
26
- icbauggw switch
26
+ auggw switch
27
27
  ```
28
28
 
29
29
  Lệnh này lấy account tiếp theo từ pool và ghi vào `~/.augment/session.json`. Chạy lại mỗi khi cần đổi account.
@@ -31,7 +31,7 @@ Lệnh này lấy account tiếp theo từ pool và ghi vào `~/.augment/session
31
31
  ### Xem trạng thái
32
32
 
33
33
  ```bash
34
- icbauggw status
34
+ auggw status
35
35
  ```
36
36
 
37
37
  Hiển thị account đang dùng, credit usage và số lượng account trong pool.
@@ -39,9 +39,8 @@ Hiển thị account đang dùng, credit usage và số lượng account trong p
39
39
  ## Lưu ý
40
40
 
41
41
  - Sau khi `switch`, restart lại Augment extension để nó đọc session mới.
42
- - Nếu gặp lỗi `Session expired`, chạy lại `icbauggw login`.
42
+ - Nếu gặp lỗi `Session expired`, chạy lại `auggw login`.
43
43
  - Nếu cần trỏ sang server khác (dev/test), set env:
44
44
  ```bash
45
- ICBAUGGW_API_URL=http://localhost:3000 icbauggw login
45
+ auggw_API_URL=http://localhost:3000 auggw login
46
46
  ```
47
-
package/bin/auggw.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require("../src/index");
package/bin/icbauggw.js CHANGED
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require('../src/index');
3
-
2
+ require("../src/index");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icbauggw",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "CLI tool for rotating Augment session accounts",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/publish.js ADDED
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const { execSync } = require('child_process');
5
+
6
+ const CLI_DIR = path.join(__dirname);
7
+ const PKG_PATH = path.join(CLI_DIR, 'package.json');
8
+ const API_PATH = path.join(CLI_DIR, 'src', 'utils', 'api.js');
9
+
10
+ const packages = [
11
+ {
12
+ name: '@itd2902/auggw',
13
+ bin: { auggw: './bin/auggw.js' },
14
+ access: '--access public',
15
+ apiUrl: 'https://auggw.quangit.site',
16
+ },
17
+ {
18
+ name: 'icbauggw',
19
+ bin: { icbauggw: './bin/icbauggw.js' },
20
+ access: '',
21
+ apiUrl: 'https://icbauggw.quangit.site',
22
+ },
23
+ ];
24
+
25
+ const version = process.argv[2];
26
+ if (!version) {
27
+ console.error('Usage: node publish.js <version>');
28
+ console.error('Example: node publish.js 1.0.2');
29
+ process.exit(1);
30
+ }
31
+
32
+ const originalPkg = fs.readFileSync(PKG_PATH, 'utf8');
33
+ const originalApi = fs.readFileSync(API_PATH, 'utf8');
34
+
35
+ for (const pkg of packages) {
36
+ const json = JSON.parse(originalPkg);
37
+ json.name = pkg.name;
38
+ json.version = version;
39
+ json.bin = pkg.bin;
40
+
41
+ fs.writeFileSync(PKG_PATH, JSON.stringify(json, null, 2) + '\n');
42
+
43
+ // Swap DEFAULT_API_URL
44
+ const apiContent = originalApi.replace(
45
+ /const DEFAULT_API_URL = ".*?";/,
46
+ `const DEFAULT_API_URL = "${pkg.apiUrl}";`
47
+ );
48
+ fs.writeFileSync(API_PATH, apiContent);
49
+
50
+ console.log(`\nPublishing ${pkg.name}@${version} → ${pkg.apiUrl}`);
51
+
52
+ try {
53
+ execSync(`npm publish ${pkg.access}`.trim(), { cwd: CLI_DIR, stdio: 'inherit' });
54
+ console.log(`${pkg.name}@${version} published.`);
55
+ } catch (err) {
56
+ console.error(`Failed to publish ${pkg.name}:`, err.message);
57
+ }
58
+ }
59
+
60
+ // Restore originals
61
+ fs.writeFileSync(PKG_PATH, originalPkg);
62
+ fs.writeFileSync(API_PATH, originalApi);
63
+ console.log('\nFiles restored.');
@@ -1,41 +1,41 @@
1
- const { apiRequest } = require('../utils/api');
2
- const { requireAuth } = require('../utils/auth');
1
+ const { apiRequest } = require("../utils/api");
2
+ const { requireAuth } = require("../utils/auth");
3
3
 
4
4
  async function statusCommand() {
5
5
  requireAuth();
6
6
 
7
7
  try {
8
- const data = await apiRequest('GET', '/api/session/status');
8
+ const data = await apiRequest("GET", "/api/session/status");
9
9
 
10
10
  if (!data.current) {
11
- console.log('ℹ️ No active session. Run: icbauggw switch');
11
+ console.log("ℹ️ No active session. Run: auggw switch");
12
12
  console.log();
13
13
  } else {
14
- console.log('📋 Current Account');
14
+ console.log("📋 Current Account");
15
15
  console.log(` Name: ${data.current.name}`);
16
16
  console.log(` Tenant: ${data.current.tenantURL}`);
17
17
  console.log(` Token: ...${data.current.accessToken}`);
18
- console.log(` Status: ${data.current.isLimited ? '🔴 Limited' : '🟢 Active'}`);
18
+ console.log(
19
+ ` Status: ${data.current.isLimited ? "🔴 Limited" : "🟢 Active"}`,
20
+ );
19
21
  if (data.current.creditTotal) {
20
22
  const used = data.current.creditRemaining || 0;
21
23
  const total = data.current.creditTotal;
22
24
  const pct = Math.round((used / total) * 100);
23
- console.log(` Credit: ${used.toLocaleString()} / ${total.toLocaleString()} (${pct}%)`);
24
- }
25
- if (data.current.currentClient) {
26
- const c = data.current.currentClient;
27
- console.log(` Client: ${c.hostname || '—'} (${c.ip || '—'})`);
25
+ console.log(
26
+ ` Credit: ${used.toLocaleString()} / ${total.toLocaleString()} (${pct}%)`,
27
+ );
28
28
  }
29
29
  console.log();
30
30
  }
31
31
 
32
- console.log('📊 Pool Status');
32
+ console.log("📊 Pool Status");
33
33
  console.log(` Active: ${data.pool.active} accounts`);
34
34
  console.log(` Limited: ${data.pool.limited} accounts`);
35
35
  console.log(` Total: ${data.pool.total} accounts`);
36
36
  } catch (err) {
37
37
  if (err.status === 401) {
38
- console.error('❌ Session expired. Please login again: icbauggw login');
38
+ console.error("❌ Session expired. Please login again: auggw login");
39
39
  } else {
40
40
  console.error(`❌ Error: ${err.message}`);
41
41
  }
@@ -44,4 +44,3 @@ async function statusCommand() {
44
44
  }
45
45
 
46
46
  module.exports = statusCommand;
47
-
@@ -1,14 +1,14 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const { apiRequest } = require('../utils/api');
4
- const { requireAuth } = require('../utils/auth');
5
- const { getSessionPath } = require('../utils/paths');
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const { apiRequest } = require("../utils/api");
4
+ const { requireAuth } = require("../utils/auth");
5
+ const { getSessionPath } = require("../utils/paths");
6
6
 
7
7
  async function switchCommand() {
8
8
  requireAuth();
9
9
 
10
10
  try {
11
- const data = await apiRequest('GET', '/api/session/next');
11
+ const data = await apiRequest("GET", "/api/session/next");
12
12
 
13
13
  const sessionPath = getSessionPath();
14
14
  const sessionDir = path.dirname(sessionPath);
@@ -24,14 +24,14 @@ async function switchCommand() {
24
24
  tenantURL: data.tenantURL,
25
25
  scopes: data.scopes,
26
26
  };
27
- fs.writeFileSync(sessionPath, JSON.stringify(session, null, 2), 'utf8');
27
+ fs.writeFileSync(sessionPath, JSON.stringify(session, null, 2), "utf8");
28
28
 
29
- console.log('✅ Session switched!');
29
+ console.log("✅ Session switched!");
30
30
  console.log(` Account: ${data.accountName}`);
31
31
  console.log(` Tenant: ${data.tenantURL}`);
32
32
  } catch (err) {
33
33
  if (err.status === 401) {
34
- console.error('❌ Session expired. Please login again: icbauggw login');
34
+ console.error("❌ Session expired. Please login again: auggw login");
35
35
  } else if (err.status === 503) {
36
36
  console.error(`❌ ${err.message}`);
37
37
  } else {
@@ -42,4 +42,3 @@ async function switchCommand() {
42
42
  }
43
43
 
44
44
  module.exports = switchCommand;
45
-
package/src/index.js CHANGED
@@ -6,7 +6,7 @@ const statusCommand = require('./commands/status');
6
6
  const program = new Command();
7
7
 
8
8
  program
9
- .name('icbauggw')
9
+ .name('auggw')
10
10
  .description('CLI tool for rotating Augment session accounts')
11
11
  .version('1.0.0');
12
12
 
package/src/utils/api.js CHANGED
@@ -5,7 +5,7 @@ const DEFAULT_API_URL = "https://icbauggw.quangit.site";
5
5
  // const DEFAULT_API_URL = "http://localhost:3000";
6
6
 
7
7
  function getBaseURL() {
8
- return process.env.ICBAUGGW_API_URL || DEFAULT_API_URL;
8
+ return process.env.auggw_API_URL || DEFAULT_API_URL;
9
9
  }
10
10
 
11
11
  function getLocalIP() {
package/src/utils/auth.js CHANGED
@@ -1,12 +1,11 @@
1
- const { loadToken } = require('./token');
1
+ const { loadToken } = require("./token");
2
2
 
3
3
  function requireAuth() {
4
4
  const token = loadToken();
5
5
  if (!token) {
6
- console.error('❌ Please login first: icbauggw login');
6
+ console.error("❌ Please login first: auggw login");
7
7
  process.exit(1);
8
8
  }
9
9
  }
10
10
 
11
11
  module.exports = { requireAuth };
12
-
@@ -1,13 +1,12 @@
1
- const os = require('os');
2
- const path = require('path');
1
+ const os = require("os");
2
+ const path = require("path");
3
3
 
4
4
  function getTokenPath() {
5
- return path.join(os.homedir(), '.icb-aug', 'token');
5
+ return path.join(os.homedir(), ".auggw", "token");
6
6
  }
7
7
 
8
8
  function getSessionPath() {
9
- return path.join(os.homedir(), '.augment', 'session.json');
9
+ return path.join(os.homedir(), ".augment", "session.json");
10
10
  }
11
11
 
12
12
  module.exports = { getTokenPath, getSessionPath };
13
-