@itd2902/auggw 1.1.4 → 1.1.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 +62 -62
- package/bin/auggw.js +2 -2
- package/bin/augteam.js +3 -3
- package/bin/icbauggw.js +1 -1
- package/package.json +1 -1
- package/publish.js +69 -69
- package/src/commands/fetch.js +145 -145
- package/src/commands/login.js +62 -62
- package/src/commands/logout.js +8 -8
- package/src/commands/status.js +57 -58
- package/src/commands/switch.js +44 -44
- package/src/commands/update.js +33 -33
- package/src/index.js +50 -51
- package/src/utils/api.js +74 -76
- package/src/utils/auth.js +11 -12
- package/src/utils/paths.js +12 -19
- package/src/utils/token.js +30 -30
- package/src/utils/update.js +24 -24
package/SETUP.md
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
# Hướng dẫn cài đặt CLI - Augment Session Rotator
|
|
2
|
-
|
|
3
|
-
## Yêu cầu
|
|
4
|
-
|
|
5
|
-
- Node.js >= 18
|
|
6
|
-
|
|
7
|
-
## Cài đặt
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install -g @itd2902/auggw
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Chạy từ source (local dev)
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
cd cli
|
|
17
|
-
npm link
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Sau đó dùng `auggw` như bình thường. Mọi thay đổi trong source sẽ có hiệu lực ngay.
|
|
21
|
-
|
|
22
|
-
Gỡ link khi không cần:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
cd cli
|
|
26
|
-
npm unlink -g
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Đăng nhập
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
auggw login
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Nhập username và password được cấp. Token sẽ lưu tại `~/gg/token`.
|
|
36
|
-
|
|
37
|
-
## Sử dụng
|
|
38
|
-
|
|
39
|
-
### Chuyển session
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
auggw switch
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
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.
|
|
46
|
-
|
|
47
|
-
### Xem trạng thái
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
auggw status
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Hiển thị account đang dùng, credit usage và số lượng account trong pool.
|
|
54
|
-
|
|
55
|
-
## Lưu ý
|
|
56
|
-
|
|
57
|
-
- Sau khi `switch`, restart lại Augment extension để nó đọc session mới.
|
|
58
|
-
- Nếu gặp lỗi `Session expired`, chạy lại `auggw login`.
|
|
59
|
-
- Nếu cần trỏ sang server khác (dev/test), set env:
|
|
60
|
-
```bash
|
|
61
|
-
auggw_API_URL=http://localhost:3000 auggw login
|
|
62
|
-
```
|
|
1
|
+
# Hướng dẫn cài đặt CLI - Augment Session Rotator
|
|
2
|
+
|
|
3
|
+
## Yêu cầu
|
|
4
|
+
|
|
5
|
+
- Node.js >= 18
|
|
6
|
+
|
|
7
|
+
## Cài đặt
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @itd2902/auggw
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Chạy từ source (local dev)
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cd cli
|
|
17
|
+
npm link
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Sau đó dùng `auggw` như bình thường. Mọi thay đổi trong source sẽ có hiệu lực ngay.
|
|
21
|
+
|
|
22
|
+
Gỡ link khi không cần:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
cd cli
|
|
26
|
+
npm unlink -g
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Đăng nhập
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
auggw login
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Nhập username và password được cấp. Token sẽ lưu tại `~/gg/token`.
|
|
36
|
+
|
|
37
|
+
## Sử dụng
|
|
38
|
+
|
|
39
|
+
### Chuyển session
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
auggw switch
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
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.
|
|
46
|
+
|
|
47
|
+
### Xem trạng thái
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
auggw status
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Hiển thị account đang dùng, credit usage và số lượng account trong pool.
|
|
54
|
+
|
|
55
|
+
## Lưu ý
|
|
56
|
+
|
|
57
|
+
- Sau khi `switch`, restart lại Augment extension để nó đọc session mới.
|
|
58
|
+
- Nếu gặp lỗi `Session expired`, chạy lại `auggw login`.
|
|
59
|
+
- Nếu cần trỏ sang server khác (dev/test), set env:
|
|
60
|
+
```bash
|
|
61
|
+
auggw_API_URL=http://localhost:3000 auggw login
|
|
62
|
+
```
|
package/bin/auggw.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
require("../src/index");
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
require("../src/index");
|
package/bin/augteam.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
require("../src/index");
|
|
3
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
require("../src/index");
|
|
3
|
+
|
package/bin/icbauggw.js
CHANGED
package/package.json
CHANGED
package/publish.js
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
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
|
-
name: 'augteam',
|
|
25
|
-
bin: { augteam: './bin/augteam.js' },
|
|
26
|
-
access: '',
|
|
27
|
-
apiUrl: 'https://augteam.quangit.site',
|
|
28
|
-
},
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
const version = process.argv[2];
|
|
32
|
-
if (!version) {
|
|
33
|
-
console.error('Usage: node publish.js <version>');
|
|
34
|
-
console.error('Example: node publish.js 1.0.2');
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const originalPkg = fs.readFileSync(PKG_PATH, 'utf8');
|
|
39
|
-
const originalApi = fs.readFileSync(API_PATH, 'utf8');
|
|
40
|
-
|
|
41
|
-
for (const pkg of packages) {
|
|
42
|
-
const json = JSON.parse(originalPkg);
|
|
43
|
-
json.name = pkg.name;
|
|
44
|
-
json.version = version;
|
|
45
|
-
json.bin = pkg.bin;
|
|
46
|
-
|
|
47
|
-
fs.writeFileSync(PKG_PATH, JSON.stringify(json, null, 2) + '\n');
|
|
48
|
-
|
|
49
|
-
// Swap DEFAULT_API_URL
|
|
50
|
-
const apiContent = originalApi.replace(
|
|
51
|
-
/const DEFAULT_API_URL = ".*?";/,
|
|
52
|
-
`const DEFAULT_API_URL = "${pkg.apiUrl}";`
|
|
53
|
-
);
|
|
54
|
-
fs.writeFileSync(API_PATH, apiContent);
|
|
55
|
-
|
|
56
|
-
console.log(`\nPublishing ${pkg.name}@${version} → ${pkg.apiUrl}`);
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
execSync(`npm publish ${pkg.access}`.trim(), { cwd: CLI_DIR, stdio: 'inherit' });
|
|
60
|
-
console.log(`${pkg.name}@${version} published.`);
|
|
61
|
-
} catch (err) {
|
|
62
|
-
console.error(`Failed to publish ${pkg.name}:`, err.message);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Restore originals
|
|
67
|
-
fs.writeFileSync(PKG_PATH, originalPkg);
|
|
68
|
-
fs.writeFileSync(API_PATH, originalApi);
|
|
69
|
-
console.log('\nFiles restored.');
|
|
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
|
+
name: 'augteam',
|
|
25
|
+
bin: { augteam: './bin/augteam.js' },
|
|
26
|
+
access: '',
|
|
27
|
+
apiUrl: 'https://augteam.quangit.site',
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const version = process.argv[2];
|
|
32
|
+
if (!version) {
|
|
33
|
+
console.error('Usage: node publish.js <version>');
|
|
34
|
+
console.error('Example: node publish.js 1.0.2');
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const originalPkg = fs.readFileSync(PKG_PATH, 'utf8');
|
|
39
|
+
const originalApi = fs.readFileSync(API_PATH, 'utf8');
|
|
40
|
+
|
|
41
|
+
for (const pkg of packages) {
|
|
42
|
+
const json = JSON.parse(originalPkg);
|
|
43
|
+
json.name = pkg.name;
|
|
44
|
+
json.version = version;
|
|
45
|
+
json.bin = pkg.bin;
|
|
46
|
+
|
|
47
|
+
fs.writeFileSync(PKG_PATH, JSON.stringify(json, null, 2) + '\n');
|
|
48
|
+
|
|
49
|
+
// Swap DEFAULT_API_URL
|
|
50
|
+
const apiContent = originalApi.replace(
|
|
51
|
+
/const DEFAULT_API_URL = ".*?";/,
|
|
52
|
+
`const DEFAULT_API_URL = "${pkg.apiUrl}";`
|
|
53
|
+
);
|
|
54
|
+
fs.writeFileSync(API_PATH, apiContent);
|
|
55
|
+
|
|
56
|
+
console.log(`\nPublishing ${pkg.name}@${version} → ${pkg.apiUrl}`);
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
execSync(`npm publish ${pkg.access}`.trim(), { cwd: CLI_DIR, stdio: 'inherit' });
|
|
60
|
+
console.log(`${pkg.name}@${version} published.`);
|
|
61
|
+
} catch (err) {
|
|
62
|
+
console.error(`Failed to publish ${pkg.name}:`, err.message);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Restore originals
|
|
67
|
+
fs.writeFileSync(PKG_PATH, originalPkg);
|
|
68
|
+
fs.writeFileSync(API_PATH, originalApi);
|
|
69
|
+
console.log('\nFiles restored.');
|
package/src/commands/fetch.js
CHANGED
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const os = require("os");
|
|
4
|
-
const readline = require("readline");
|
|
5
|
-
const { apiRequest } = require("../utils/api");
|
|
6
|
-
const { requireAuth } = require("../utils/auth");
|
|
7
|
-
|
|
8
|
-
function ask(question) {
|
|
9
|
-
return new Promise((resolve) => {
|
|
10
|
-
const rl = readline.createInterface({
|
|
11
|
-
input: process.stdin,
|
|
12
|
-
output: process.stdout,
|
|
13
|
-
});
|
|
14
|
-
rl.question(question, (answer) => {
|
|
15
|
-
rl.close();
|
|
16
|
-
resolve(answer.trim());
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function getAugmentDir() {
|
|
22
|
-
return path.join(os.homedir(), ".augment");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function getClaudeDir() {
|
|
26
|
-
return path.join(os.homedir(), ".claude");
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function writeFile(filePath, content) {
|
|
30
|
-
const dir = path.dirname(filePath);
|
|
31
|
-
if (!fs.existsSync(dir)) {
|
|
32
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
33
|
-
}
|
|
34
|
-
fs.writeFileSync(filePath, content, "utf8");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function installToAugment(data) {
|
|
38
|
-
const baseDir = getAugmentDir();
|
|
39
|
-
let count = 0;
|
|
40
|
-
|
|
41
|
-
for (const cmd of data.commands) {
|
|
42
|
-
writeFile(path.join(baseDir, "commands", cmd.name), cmd.content);
|
|
43
|
-
count++;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
for (const skill of data.skills) {
|
|
47
|
-
writeFile(path.join(baseDir, "skills", skill.name, "SKILL.md"), skill.content);
|
|
48
|
-
count++;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
for (const agent of data.agents || []) {
|
|
52
|
-
writeFile(path.join(baseDir, "agents", agent.name), agent.content);
|
|
53
|
-
count++;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return count;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function installToClaude(data) {
|
|
60
|
-
const baseDir = getClaudeDir();
|
|
61
|
-
let count = 0;
|
|
62
|
-
|
|
63
|
-
for (const cmd of data.commands) {
|
|
64
|
-
writeFile(path.join(baseDir, "commands", cmd.name), cmd.content);
|
|
65
|
-
count++;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
for (const skill of data.skills) {
|
|
69
|
-
writeFile(path.join(baseDir, "commands", skill.name, "SKILL.md"), skill.content);
|
|
70
|
-
count++;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
for (const agent of data.agents || []) {
|
|
74
|
-
writeFile(path.join(baseDir, "agents", agent.name), agent.content);
|
|
75
|
-
count++;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return count;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async function fetchPrompts() {
|
|
82
|
-
console.log("📦 Fetch prompts (commands & skills)\n");
|
|
83
|
-
console.log(" 1) Augment only (~/.augment/)");
|
|
84
|
-
console.log(" 2) Claude only (~/.claude/)");
|
|
85
|
-
console.log(" 3) Both\n");
|
|
86
|
-
|
|
87
|
-
const choice = await ask("Chọn (1/2/3): ");
|
|
88
|
-
|
|
89
|
-
if (!["1", "2", "3"].includes(choice)) {
|
|
90
|
-
console.error("❌ Lựa chọn không hợp lệ. Vui lòng chọn 1, 2 hoặc 3.");
|
|
91
|
-
process.exit(1);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
console.log("\n⏳ Fetching prompts from server...");
|
|
95
|
-
const data = await apiRequest("GET", "/api/prompts");
|
|
96
|
-
|
|
97
|
-
const totalItems = data.commands.length + data.skills.length + (data.agents || []).length;
|
|
98
|
-
if (totalItems === 0) {
|
|
99
|
-
console.log("ℹ️ Không có prompts nào trên server.");
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
console.log(
|
|
104
|
-
` Found: ${data.commands.length} command(s), ${data.skills.length} skill(s), ${(data.agents || []).length} agent(s)\n`,
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
if (choice === "1" || choice === "3") {
|
|
108
|
-
const count = installToAugment(data);
|
|
109
|
-
console.log(`✅ Augment: ${count} file(s) → ${getAugmentDir()}`);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (choice === "2" || choice === "3") {
|
|
113
|
-
const count = installToClaude(data);
|
|
114
|
-
console.log(`✅ Claude: ${count} file(s) → ${getClaudeDir()}`);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
console.log("\n🎉 Done!");
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
async function fetchCommand(options) {
|
|
121
|
-
requireAuth();
|
|
122
|
-
|
|
123
|
-
if (!options.prompts) {
|
|
124
|
-
console.log("Usage: auggw fetch --prompts");
|
|
125
|
-
console.log("\nOptions:");
|
|
126
|
-
console.log(" --prompts Fetch commands & skills to ~/.augment and/or ~/.claude");
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
try {
|
|
131
|
-
if (options.prompts) {
|
|
132
|
-
await fetchPrompts();
|
|
133
|
-
}
|
|
134
|
-
} catch (err) {
|
|
135
|
-
if (err.status === 401) {
|
|
136
|
-
console.error("❌ Session expired. Please login again: auggw login");
|
|
137
|
-
} else {
|
|
138
|
-
console.error(`❌ Error: ${err.message}`);
|
|
139
|
-
}
|
|
140
|
-
process.exit(1);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
module.exports = fetchCommand;
|
|
145
|
-
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const os = require("os");
|
|
4
|
+
const readline = require("readline");
|
|
5
|
+
const { apiRequest } = require("../utils/api");
|
|
6
|
+
const { requireAuth } = require("../utils/auth");
|
|
7
|
+
|
|
8
|
+
function ask(question) {
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
const rl = readline.createInterface({
|
|
11
|
+
input: process.stdin,
|
|
12
|
+
output: process.stdout,
|
|
13
|
+
});
|
|
14
|
+
rl.question(question, (answer) => {
|
|
15
|
+
rl.close();
|
|
16
|
+
resolve(answer.trim());
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getAugmentDir() {
|
|
22
|
+
return path.join(os.homedir(), ".augment");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getClaudeDir() {
|
|
26
|
+
return path.join(os.homedir(), ".claude");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function writeFile(filePath, content) {
|
|
30
|
+
const dir = path.dirname(filePath);
|
|
31
|
+
if (!fs.existsSync(dir)) {
|
|
32
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
33
|
+
}
|
|
34
|
+
fs.writeFileSync(filePath, content, "utf8");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function installToAugment(data) {
|
|
38
|
+
const baseDir = getAugmentDir();
|
|
39
|
+
let count = 0;
|
|
40
|
+
|
|
41
|
+
for (const cmd of data.commands) {
|
|
42
|
+
writeFile(path.join(baseDir, "commands", cmd.name), cmd.content);
|
|
43
|
+
count++;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
for (const skill of data.skills) {
|
|
47
|
+
writeFile(path.join(baseDir, "skills", skill.name, "SKILL.md"), skill.content);
|
|
48
|
+
count++;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
for (const agent of data.agents || []) {
|
|
52
|
+
writeFile(path.join(baseDir, "agents", agent.name), agent.content);
|
|
53
|
+
count++;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return count;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function installToClaude(data) {
|
|
60
|
+
const baseDir = getClaudeDir();
|
|
61
|
+
let count = 0;
|
|
62
|
+
|
|
63
|
+
for (const cmd of data.commands) {
|
|
64
|
+
writeFile(path.join(baseDir, "commands", cmd.name), cmd.content);
|
|
65
|
+
count++;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
for (const skill of data.skills) {
|
|
69
|
+
writeFile(path.join(baseDir, "commands", skill.name, "SKILL.md"), skill.content);
|
|
70
|
+
count++;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
for (const agent of data.agents || []) {
|
|
74
|
+
writeFile(path.join(baseDir, "agents", agent.name), agent.content);
|
|
75
|
+
count++;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return count;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function fetchPrompts() {
|
|
82
|
+
console.log("📦 Fetch prompts (commands & skills)\n");
|
|
83
|
+
console.log(" 1) Augment only (~/.augment/)");
|
|
84
|
+
console.log(" 2) Claude only (~/.claude/)");
|
|
85
|
+
console.log(" 3) Both\n");
|
|
86
|
+
|
|
87
|
+
const choice = await ask("Chọn (1/2/3): ");
|
|
88
|
+
|
|
89
|
+
if (!["1", "2", "3"].includes(choice)) {
|
|
90
|
+
console.error("❌ Lựa chọn không hợp lệ. Vui lòng chọn 1, 2 hoặc 3.");
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
console.log("\n⏳ Fetching prompts from server...");
|
|
95
|
+
const data = await apiRequest("GET", "/api/prompts");
|
|
96
|
+
|
|
97
|
+
const totalItems = data.commands.length + data.skills.length + (data.agents || []).length;
|
|
98
|
+
if (totalItems === 0) {
|
|
99
|
+
console.log("ℹ️ Không có prompts nào trên server.");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
console.log(
|
|
104
|
+
` Found: ${data.commands.length} command(s), ${data.skills.length} skill(s), ${(data.agents || []).length} agent(s)\n`,
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
if (choice === "1" || choice === "3") {
|
|
108
|
+
const count = installToAugment(data);
|
|
109
|
+
console.log(`✅ Augment: ${count} file(s) → ${getAugmentDir()}`);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (choice === "2" || choice === "3") {
|
|
113
|
+
const count = installToClaude(data);
|
|
114
|
+
console.log(`✅ Claude: ${count} file(s) → ${getClaudeDir()}`);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
console.log("\n🎉 Done!");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function fetchCommand(options) {
|
|
121
|
+
requireAuth();
|
|
122
|
+
|
|
123
|
+
if (!options.prompts) {
|
|
124
|
+
console.log("Usage: auggw fetch --prompts");
|
|
125
|
+
console.log("\nOptions:");
|
|
126
|
+
console.log(" --prompts Fetch commands & skills to ~/.augment and/or ~/.claude");
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
try {
|
|
131
|
+
if (options.prompts) {
|
|
132
|
+
await fetchPrompts();
|
|
133
|
+
}
|
|
134
|
+
} catch (err) {
|
|
135
|
+
if (err.status === 401) {
|
|
136
|
+
console.error("❌ Session expired. Please login again: auggw login");
|
|
137
|
+
} else {
|
|
138
|
+
console.error(`❌ Error: ${err.message}`);
|
|
139
|
+
}
|
|
140
|
+
process.exit(1);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
module.exports = fetchCommand;
|
|
145
|
+
|