@dccxx/auggiegw 1.0.4 → 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 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
@@ -1,2 +1,3 @@
1
1
  AUGMENT_GATEWAY_URL=https://augmentgateway.1app.space
2
+ AUGGIEGW_AUTH_TOKEN=
2
3
 
package/README.md CHANGED
@@ -32,18 +32,55 @@ bun run clean
32
32
 
33
33
  ## Usage
34
34
 
35
- ### As a CLI tool
35
+ ### Authentication
36
36
 
37
- After building, you can run the CLI command:
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
- node dist/cli.js
44
+ export AUGGIEGW_AUTH_TOKEN=your_token_here
41
45
  ```
42
46
 
43
- Or if installed globally:
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
- console.log(`Fetching prompts page ${currentPage}...`);
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);
@@ -218,11 +231,9 @@ async function handleLogin(usernameArg, passwordArg) {
218
231
  const authData = {
219
232
  username,
220
233
  token: loginResponse.data.token,
221
- user: loginResponse.data.user,
222
234
  };
223
235
  await saveAuthData(authData);
224
236
  console.log('Login successful! Token saved.');
225
- console.log(`Welcome, ${loginResponse.data.user.display_name}!`);
226
237
  }
227
238
  catch (error) {
228
239
  console.error(`Login failed: ${error}`);
@@ -240,29 +251,30 @@ async function handleLogout() {
240
251
  }
241
252
  }
242
253
  async function handleFetch() {
254
+ const spinner = ora('Initializing...').start();
243
255
  try {
244
256
  const config = loadConfig();
245
- const authData = await loadAuthData();
246
- console.log('Fetching proxy configuration...');
247
- const proxyResponse = await getProxy(authData.token, config.apiUrl);
257
+ const token = await getAuthToken();
258
+ spinner.text = 'Fetching proxy configuration...';
259
+ const proxyResponse = await getProxy(token, config.apiUrl);
248
260
  if (!proxyResponse.data || proxyResponse.data.length === 0) {
249
- console.error('Error: No proxy data available');
261
+ spinner.fail('No proxy data available');
250
262
  process.exit(1);
251
263
  }
252
264
  const firstProxy = proxyResponse.data[0];
253
265
  if (!firstProxy) {
254
- console.error('Error: No proxy data available');
266
+ spinner.fail('No proxy data available');
255
267
  process.exit(1);
256
268
  }
257
269
  const proxyId = firstProxy.http_user;
258
270
  const rawPassword = firstProxy.http_password;
259
271
  const atIndex = rawPassword.indexOf('@');
260
272
  if (atIndex === -1) {
261
- console.error('Error: Invalid proxy password format');
273
+ spinner.fail('Invalid proxy password format');
262
274
  process.exit(1);
263
275
  }
264
276
  const proxyPassword = rawPassword.substring(0, atIndex);
265
- console.log('Authenticating proxy...');
277
+ spinner.text = 'Authenticating proxy...';
266
278
  const authResponse = await authProxy(proxyId, proxyPassword, config.apiUrl);
267
279
  if (authResponse.success && authResponse.data) {
268
280
  const augmentSession = {
@@ -273,31 +285,62 @@ async function handleFetch() {
273
285
  await saveAugmentSession(augmentSession);
274
286
  try {
275
287
  await execAsync('auggie session delete');
276
- console.log('Session configured successfully');
277
288
  }
278
- catch (error) {
279
- console.warn(`Warning: Failed to run auggie session delete: ${error.message}`);
289
+ catch {
290
+ // Silently ignore auggie session delete errors
280
291
  }
281
- console.log('Fetching prompts...');
282
- const allPrompts = await getAllPrompts(authData.token, config.apiUrl);
292
+ spinner.text = 'Fetching prompts...';
293
+ const allPrompts = await getAllPrompts(token, config.apiUrl, spinner);
283
294
  if (allPrompts.length > 0) {
284
- console.log(`Saving ${allPrompts.length} prompts...`);
295
+ spinner.text = `Saving ${allPrompts.length} prompts...`;
285
296
  for (const prompt of allPrompts) {
286
297
  await savePromptToFile(prompt);
287
- console.log(`Saved: ${prompt.command}.md`);
288
298
  }
289
- console.log('All prompts saved successfully');
299
+ spinner.succeed(`Successfully saved ${allPrompts.length} prompts`);
290
300
  }
291
301
  else {
292
- console.log('No prompts found');
302
+ spinner.warn('No prompts found');
293
303
  }
294
304
  }
295
305
  }
296
306
  catch (error) {
297
- console.error(`Fetch failed: ${error}`);
307
+ spinner.fail(`Fetch failed: ${error}`);
298
308
  process.exit(1);
299
309
  }
300
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
+ }
301
344
  const program = new Command();
302
345
  program.name('auggiegw').description('CLI tool for auggiegw authentication').version('1.0.0');
303
346
  program
@@ -309,5 +352,19 @@ program
309
352
  .command('fetch')
310
353
  .description('Fetch proxy configuration and authenticate')
311
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
+ });
312
369
  program.parse();
313
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.4",
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
+ }