@dccxx/auggiegw 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/.env +1 -1
- package/.env.example +1 -0
- package/README.md +42 -5
- package/dist/cli.js +94 -26
- package/justfile +46 -0
- package/package.json +3 -2
- package/scripts/bump-version.js +47 -0
package/.env
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
AUGMENT_GATEWAY_URL=https://augmentgateway.1app.space
|
|
2
|
-
|
|
2
|
+
AUGGIEGW_AUTH_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsInVzZXJuYW1lIjoicm9vdCIsImVtYWlsIjoiIiwiZGlzcGxheU5hbWUiOiJSb290IFVzZXIiLCJyb2xlIjoxMDAsInN0YXR1cyI6MSwibG9jYWxSb2xlIjp7InJvbGVUeXBlIjoiQURNSU4iLCJjcmVhdGVkQXQiOiIyMDI1LTA4LTI1VDA5OjQ2OjAyLjM5M1oiLCJ1cGRhdGVkQXQiOiIyMDI1LTA4LTI1VDA5OjQ2OjAyLjM5M1oifSwidGhpcmRQYXJ0eVNlc3Npb24iOnsiYWNjZXNzVG9rZW4iOiIiLCJjb29raWVzIjpbInNlc3Npb249TVRjMU9UZ3lNelF3Tlh4RVdEaEZRVkZNWDJkQlFVSkZRVVZSUVVGQ2MxODBRVUZDUVZwNlpFaEtjR0p0WTAxRFFVRkhZek5TYUdSSVZucEJNbXgxWkVGUlEwRkJTVWRqTTFKNVlWYzFia1JCVVVGQmJXeHJRVEpzZFdSQlVVTkJRVWxIWXpOU2VXRlhOVzVFUVc5QlEwaFdlbHBZU25WWlZ6RnNRbTVPTUdOdGJIVmFkM2RIUVVGU2VXSXlPVEJDYms0d1kyMXNkVnAzZDBkQlFWSjVZako0YkVFeWJIVmtRVkZFUVZCZlNYeHlDWVdRbzF3Z3o2ZHZOUk5uQ3JYNEhlWWF6Wm91T1NPak5BTnI0c2FGSUE9PTsgUGF0aD0vOyBFeHBpcmVzPVRodSIsIjA2IE5vdiAyMDI1IDA3OjUwOjA1IEdNVDsgTWF4LUFnZT0yNTkyMDAwIl19LCJxdW90YSI6MCwidXNlZFF1b3RhIjowLCJyZXF1ZXN0Q291bnQiOjAsImdyb3VwIjoiIiwiaWF0IjoxNzU5ODIzNDA1LCJleHAiOjE3OTEzNTk0MDUsImlzcyI6ImF1Z21lbnQtZ2F0ZXdheSJ9.9FgtSkgFWl3b7HHIGL9IhP3NPZul9ESseRQogyw-KN0
|
package/.env.example
CHANGED
package/README.md
CHANGED
|
@@ -32,18 +32,55 @@ bun run clean
|
|
|
32
32
|
|
|
33
33
|
## Usage
|
|
34
34
|
|
|
35
|
-
###
|
|
35
|
+
### Authentication
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
There are two ways to authenticate with auggiegw:
|
|
38
|
+
|
|
39
|
+
#### 1. Using Environment Variable (Recommended for CI/CD)
|
|
40
|
+
|
|
41
|
+
Set the `AUGGIEGW_AUTH_TOKEN` environment variable with your authentication token:
|
|
38
42
|
|
|
39
43
|
```bash
|
|
40
|
-
|
|
44
|
+
export AUGGIEGW_AUTH_TOKEN=your_token_here
|
|
41
45
|
```
|
|
42
46
|
|
|
43
|
-
|
|
47
|
+
When this environment variable is set, the CLI will use it directly without requiring login or auth.json file.
|
|
48
|
+
|
|
49
|
+
#### 2. Using Login Command
|
|
50
|
+
|
|
51
|
+
Login with your credentials:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
auggiegw login [username] [password]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This will save your credentials to `~/.auggiegw/auth.json` for future use.
|
|
58
|
+
|
|
59
|
+
### CLI Commands
|
|
60
|
+
|
|
61
|
+
#### Login
|
|
62
|
+
```bash
|
|
63
|
+
auggiegw login [username] [password]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### Logout
|
|
67
|
+
```bash
|
|
68
|
+
auggiegw logout
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
#### Fetch proxy configuration and prompts
|
|
72
|
+
```bash
|
|
73
|
+
auggiegw fetch
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
#### Forward command to auggie CLI
|
|
77
|
+
```bash
|
|
78
|
+
auggiegw auggie [args...]
|
|
79
|
+
```
|
|
44
80
|
|
|
81
|
+
#### Execute custom command
|
|
45
82
|
```bash
|
|
46
|
-
auggiegw
|
|
83
|
+
auggiegw exec <command> [args...]
|
|
47
84
|
```
|
|
48
85
|
|
|
49
86
|
### As a library
|
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { exec } from 'node:child_process';
|
|
2
|
+
import { exec, spawn } from 'node:child_process';
|
|
3
3
|
import * as fs from 'node:fs/promises';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
4
5
|
import * as os from 'node:os';
|
|
5
6
|
import * as path from 'node:path';
|
|
6
7
|
import * as readline from 'node:readline/promises';
|
|
7
8
|
import { promisify } from 'node:util';
|
|
8
9
|
import { Command } from 'commander';
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
const ora = require('ora');
|
|
9
12
|
const execAsync = promisify(exec);
|
|
10
13
|
const AUTH_DIR = path.join(os.homedir(), '.auggiegw');
|
|
11
14
|
const AUTH_FILE = path.join(AUTH_DIR, 'auth.json');
|
|
@@ -28,6 +31,14 @@ async function saveAuthData(data) {
|
|
|
28
31
|
await ensureAuthDirectory();
|
|
29
32
|
await fs.writeFile(AUTH_FILE, JSON.stringify(data, null, 2), 'utf-8');
|
|
30
33
|
}
|
|
34
|
+
async function getAuthToken() {
|
|
35
|
+
const envToken = process.env.AUGGIEGW_AUTH_TOKEN;
|
|
36
|
+
if (envToken) {
|
|
37
|
+
return envToken;
|
|
38
|
+
}
|
|
39
|
+
const authData = await loadAuthData();
|
|
40
|
+
return authData.token;
|
|
41
|
+
}
|
|
31
42
|
async function loadAuthData() {
|
|
32
43
|
try {
|
|
33
44
|
const data = await fs.readFile(AUTH_FILE, 'utf-8');
|
|
@@ -75,13 +86,15 @@ async function getPrompts(token, apiUrl, page, limit) {
|
|
|
75
86
|
}
|
|
76
87
|
return data;
|
|
77
88
|
}
|
|
78
|
-
async function getAllPrompts(token, apiUrl) {
|
|
89
|
+
async function getAllPrompts(token, apiUrl, spinner) {
|
|
79
90
|
const allPrompts = [];
|
|
80
91
|
const limit = 10;
|
|
81
92
|
let currentPage = 1;
|
|
82
93
|
let hasMorePages = true;
|
|
83
94
|
while (hasMorePages) {
|
|
84
|
-
|
|
95
|
+
if (spinner) {
|
|
96
|
+
spinner.text = `Fetching prompts (page ${currentPage})...`;
|
|
97
|
+
}
|
|
85
98
|
const response = await getPrompts(token, apiUrl, currentPage, limit);
|
|
86
99
|
if (response.data.prompts && response.data.prompts.length > 0) {
|
|
87
100
|
allPrompts.push(...response.data.prompts);
|
|
@@ -196,11 +209,19 @@ async function authProxy(proxyId, proxyPassword, apiUrl) {
|
|
|
196
209
|
const data = (await response.json());
|
|
197
210
|
return data;
|
|
198
211
|
}
|
|
199
|
-
async function handleLogin() {
|
|
212
|
+
async function handleLogin(usernameArg, passwordArg) {
|
|
200
213
|
try {
|
|
201
214
|
const config = loadConfig();
|
|
202
|
-
|
|
203
|
-
|
|
215
|
+
let username;
|
|
216
|
+
let password;
|
|
217
|
+
if (usernameArg && passwordArg) {
|
|
218
|
+
username = usernameArg;
|
|
219
|
+
password = passwordArg;
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
username = await promptInput('Username: ');
|
|
223
|
+
password = await promptInput('Password: ', true);
|
|
224
|
+
}
|
|
204
225
|
if (!username || !password) {
|
|
205
226
|
console.error('Error: Username and password are required');
|
|
206
227
|
process.exit(1);
|
|
@@ -210,11 +231,9 @@ async function handleLogin() {
|
|
|
210
231
|
const authData = {
|
|
211
232
|
username,
|
|
212
233
|
token: loginResponse.data.token,
|
|
213
|
-
user: loginResponse.data.user,
|
|
214
234
|
};
|
|
215
235
|
await saveAuthData(authData);
|
|
216
236
|
console.log('Login successful! Token saved.');
|
|
217
|
-
console.log(`Welcome, ${loginResponse.data.user.display_name}!`);
|
|
218
237
|
}
|
|
219
238
|
catch (error) {
|
|
220
239
|
console.error(`Login failed: ${error}`);
|
|
@@ -232,29 +251,30 @@ async function handleLogout() {
|
|
|
232
251
|
}
|
|
233
252
|
}
|
|
234
253
|
async function handleFetch() {
|
|
254
|
+
const spinner = ora('Initializing...').start();
|
|
235
255
|
try {
|
|
236
256
|
const config = loadConfig();
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
const proxyResponse = await getProxy(
|
|
257
|
+
const token = await getAuthToken();
|
|
258
|
+
spinner.text = 'Fetching proxy configuration...';
|
|
259
|
+
const proxyResponse = await getProxy(token, config.apiUrl);
|
|
240
260
|
if (!proxyResponse.data || proxyResponse.data.length === 0) {
|
|
241
|
-
|
|
261
|
+
spinner.fail('No proxy data available');
|
|
242
262
|
process.exit(1);
|
|
243
263
|
}
|
|
244
264
|
const firstProxy = proxyResponse.data[0];
|
|
245
265
|
if (!firstProxy) {
|
|
246
|
-
|
|
266
|
+
spinner.fail('No proxy data available');
|
|
247
267
|
process.exit(1);
|
|
248
268
|
}
|
|
249
269
|
const proxyId = firstProxy.http_user;
|
|
250
270
|
const rawPassword = firstProxy.http_password;
|
|
251
271
|
const atIndex = rawPassword.indexOf('@');
|
|
252
272
|
if (atIndex === -1) {
|
|
253
|
-
|
|
273
|
+
spinner.fail('Invalid proxy password format');
|
|
254
274
|
process.exit(1);
|
|
255
275
|
}
|
|
256
276
|
const proxyPassword = rawPassword.substring(0, atIndex);
|
|
257
|
-
|
|
277
|
+
spinner.text = 'Authenticating proxy...';
|
|
258
278
|
const authResponse = await authProxy(proxyId, proxyPassword, config.apiUrl);
|
|
259
279
|
if (authResponse.success && authResponse.data) {
|
|
260
280
|
const augmentSession = {
|
|
@@ -265,38 +285,86 @@ async function handleFetch() {
|
|
|
265
285
|
await saveAugmentSession(augmentSession);
|
|
266
286
|
try {
|
|
267
287
|
await execAsync('auggie session delete');
|
|
268
|
-
console.log('Session configured successfully');
|
|
269
288
|
}
|
|
270
|
-
catch
|
|
271
|
-
|
|
289
|
+
catch {
|
|
290
|
+
// Silently ignore auggie session delete errors
|
|
272
291
|
}
|
|
273
|
-
|
|
274
|
-
const allPrompts = await getAllPrompts(
|
|
292
|
+
spinner.text = 'Fetching prompts...';
|
|
293
|
+
const allPrompts = await getAllPrompts(token, config.apiUrl, spinner);
|
|
275
294
|
if (allPrompts.length > 0) {
|
|
276
|
-
|
|
295
|
+
spinner.text = `Saving ${allPrompts.length} prompts...`;
|
|
277
296
|
for (const prompt of allPrompts) {
|
|
278
297
|
await savePromptToFile(prompt);
|
|
279
|
-
console.log(`Saved: ${prompt.command}.md`);
|
|
280
298
|
}
|
|
281
|
-
|
|
299
|
+
spinner.succeed(`Successfully saved ${allPrompts.length} prompts`);
|
|
282
300
|
}
|
|
283
301
|
else {
|
|
284
|
-
|
|
302
|
+
spinner.warn('No prompts found');
|
|
285
303
|
}
|
|
286
304
|
}
|
|
287
305
|
}
|
|
288
306
|
catch (error) {
|
|
289
|
-
|
|
307
|
+
spinner.fail(`Fetch failed: ${error}`);
|
|
290
308
|
process.exit(1);
|
|
291
309
|
}
|
|
292
310
|
}
|
|
311
|
+
async function handleAuggie(args) {
|
|
312
|
+
await handleFetch();
|
|
313
|
+
const auggieProcess = spawn('auggie', args, {
|
|
314
|
+
stdio: 'inherit',
|
|
315
|
+
shell: true,
|
|
316
|
+
});
|
|
317
|
+
auggieProcess.on('error', (error) => {
|
|
318
|
+
console.error(`Failed to execute auggie: ${error.message}`);
|
|
319
|
+
process.exit(1);
|
|
320
|
+
});
|
|
321
|
+
auggieProcess.on('exit', (code) => {
|
|
322
|
+
process.exit(code ?? 0);
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
async function handleExec(command, args) {
|
|
326
|
+
if (!command) {
|
|
327
|
+
console.error('Error: Command is required');
|
|
328
|
+
console.error('Usage: auggiegw exec <command> [args...]');
|
|
329
|
+
process.exit(1);
|
|
330
|
+
}
|
|
331
|
+
await handleFetch();
|
|
332
|
+
const childProcess = spawn(command, args, {
|
|
333
|
+
stdio: 'inherit',
|
|
334
|
+
shell: true,
|
|
335
|
+
});
|
|
336
|
+
childProcess.on('error', (error) => {
|
|
337
|
+
console.error(`Failed to execute ${command}: ${error.message}`);
|
|
338
|
+
process.exit(1);
|
|
339
|
+
});
|
|
340
|
+
childProcess.on('exit', (code) => {
|
|
341
|
+
process.exit(code ?? 0);
|
|
342
|
+
});
|
|
343
|
+
}
|
|
293
344
|
const program = new Command();
|
|
294
345
|
program.name('auggiegw').description('CLI tool for auggiegw authentication').version('1.0.0');
|
|
295
|
-
program
|
|
346
|
+
program
|
|
347
|
+
.command('login [username] [password]')
|
|
348
|
+
.description('Login and store credentials')
|
|
349
|
+
.action(handleLogin);
|
|
296
350
|
program.command('logout').description('Logout and remove stored credentials').action(handleLogout);
|
|
297
351
|
program
|
|
298
352
|
.command('fetch')
|
|
299
353
|
.description('Fetch proxy configuration and authenticate')
|
|
300
354
|
.action(handleFetch);
|
|
355
|
+
program
|
|
356
|
+
.command('auggie [args...]')
|
|
357
|
+
.description('Forward command to auggie CLI')
|
|
358
|
+
.allowUnknownOption()
|
|
359
|
+
.action((args) => {
|
|
360
|
+
handleAuggie(args || []);
|
|
361
|
+
});
|
|
362
|
+
program
|
|
363
|
+
.command('exec <command> [args...]')
|
|
364
|
+
.description('Execute any custom command')
|
|
365
|
+
.allowUnknownOption()
|
|
366
|
+
.action((command, args) => {
|
|
367
|
+
handleExec(command, args);
|
|
368
|
+
});
|
|
301
369
|
program.parse();
|
|
302
370
|
//# sourceMappingURL=cli.js.map
|
package/justfile
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
set windows-shell := ["powershell.exe", "-NoLogo", "-Command"]
|
|
2
|
+
set shell := ["bash", "-cu"]
|
|
3
|
+
|
|
4
|
+
# Default recipe - show available commands
|
|
5
|
+
default:
|
|
6
|
+
@just --list
|
|
7
|
+
|
|
8
|
+
# Build the TypeScript project
|
|
9
|
+
build:
|
|
10
|
+
bunx tsc
|
|
11
|
+
|
|
12
|
+
# Run linter with auto-fix
|
|
13
|
+
lint:
|
|
14
|
+
bunx biome check --write
|
|
15
|
+
|
|
16
|
+
# Clean the dist directory
|
|
17
|
+
clean:
|
|
18
|
+
@{{ if os_family() == "windows" { "if (Test-Path dist) { Remove-Item -Recurse -Force dist }" } else { "rm -rf dist" } }}
|
|
19
|
+
|
|
20
|
+
# Publish package to npm (auto-increments version)
|
|
21
|
+
[confirm("Are you sure you want to publish to npm?")]
|
|
22
|
+
publish:
|
|
23
|
+
node scripts/bump-version.js
|
|
24
|
+
npm publish --access public
|
|
25
|
+
|
|
26
|
+
# Development: Run login command
|
|
27
|
+
dev-login:
|
|
28
|
+
bun run src/cli.ts login
|
|
29
|
+
|
|
30
|
+
# Development: Run fetch command
|
|
31
|
+
dev-fetch:
|
|
32
|
+
bun run src/cli.ts fetch
|
|
33
|
+
|
|
34
|
+
dev-auggie:
|
|
35
|
+
bun run src/cli.ts auggie --print "hi"
|
|
36
|
+
|
|
37
|
+
# Build and then publish (recommended workflow)
|
|
38
|
+
[confirm("This will build and publish. Continue?")]
|
|
39
|
+
release: lint rebuild publish
|
|
40
|
+
|
|
41
|
+
# Clean and rebuild
|
|
42
|
+
rebuild: clean build
|
|
43
|
+
|
|
44
|
+
# Run all quality checks (lint + build)
|
|
45
|
+
check: lint build
|
|
46
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dccxx/auggiegw",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "A Node.js TypeScript package",
|
|
5
5
|
"main": "./dist/cli.js",
|
|
6
6
|
"types": "./dist/cli.d.ts",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"node": ">=18.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"commander": "^14.0.1"
|
|
28
|
+
"commander": "^14.0.1",
|
|
29
|
+
"ora": "^5.4.1"
|
|
29
30
|
}
|
|
30
31
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execSync } from 'node:child_process';
|
|
4
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { dirname, join } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = dirname(__filename);
|
|
10
|
+
|
|
11
|
+
const packageJsonPath = join(__dirname, '..', 'package.json');
|
|
12
|
+
|
|
13
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
14
|
+
|
|
15
|
+
const currentVersion = packageJson.version;
|
|
16
|
+
const versionParts = currentVersion.split('.');
|
|
17
|
+
|
|
18
|
+
if (versionParts.length !== 3) {
|
|
19
|
+
console.error(`Invalid version format: ${currentVersion}`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const [major, minor, patch] = versionParts.map(Number);
|
|
24
|
+
|
|
25
|
+
if (versionParts.some((part) => Number.isNaN(Number(part)))) {
|
|
26
|
+
console.error(`Invalid version format: ${currentVersion}`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const newVersion = `${major}.${minor}.${patch + 1}`;
|
|
31
|
+
|
|
32
|
+
packageJson.version = newVersion;
|
|
33
|
+
|
|
34
|
+
writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, 'utf-8');
|
|
35
|
+
|
|
36
|
+
console.log(`Version bumped: ${currentVersion} → ${newVersion}`);
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
execSync('git add package.json', { stdio: 'inherit' });
|
|
40
|
+
execSync(`git commit -m "chore: bump version to ${newVersion}"`, {
|
|
41
|
+
stdio: 'inherit',
|
|
42
|
+
});
|
|
43
|
+
console.log('Committed version bump to git');
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error('Failed to commit version bump:', error.message);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|