@dccxx/auggiegw 1.0.5 → 1.0.7

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.
Files changed (3) hide show
  1. package/README.md +421 -42
  2. package/dist/cli.js +53 -14
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,104 +1,483 @@
1
1
  # @dccxx/auggiegw
2
2
 
3
- A Node.js TypeScript package with CLI support.
3
+ A CLI tool for managing Augment Gateway authentication, proxy configuration, and custom prompts. This tool simplifies the workflow of authenticating with Augment Gateway, fetching proxy configurations, and managing custom prompts for the Augment AI assistant.
4
+
5
+ ## Features
6
+
7
+ - 🔐 **Authentication Management**: Login/logout with secure credential storage
8
+ - 🌐 **Proxy Configuration**: Automatic proxy setup and authentication
9
+ - 📝 **Custom Prompts**: Fetch and save custom prompts to `~/.augment/commands/`
10
+ - 🔄 **Auggie Integration**: Seamlessly forward commands to the Auggie CLI
11
+ - ⚡ **Command Execution**: Execute any command with automatic session setup
4
12
 
5
13
  ## Installation
6
14
 
7
- Install dependencies:
15
+ ```bash
16
+ npm install -g @dccxx/auggiegw
17
+ ```
18
+
19
+ or with Bun:
8
20
 
9
21
  ```bash
10
- bun install
22
+ bun install -g @dccxx/auggiegw
11
23
  ```
12
24
 
13
- ## Development
25
+ ## Quick Start
14
26
 
15
- Build the project:
27
+ 1. **Login to Augment Gateway**:
28
+ ```bash
29
+ auggiegw login
30
+ ```
31
+ You'll be prompted for your username and password.
16
32
 
33
+ 2. **Fetch Configuration**:
34
+ ```bash
35
+ auggiegw fetch
36
+ ```
37
+ This fetches proxy configuration, authenticates, and downloads custom prompts.
38
+
39
+ ## Global Options
40
+
41
+ The following options can be used with any command that triggers session management (`fetch`, `auggie`, `exec`):
42
+
43
+ - **`--preserve-session`**: Preserve Auggie session and chat history when switching accounts
44
+ - **`--delete-session`**: Explicitly delete Auggie session and chat history (default behavior)
45
+
46
+ **Examples**:
17
47
  ```bash
18
- bun run build
48
+ # Preserve chat history when fetching
49
+ auggiegw --preserve-session fetch
50
+
51
+ # Preserve chat history when running auggie
52
+ auggiegw --preserve-session auggie --help
53
+
54
+ # Explicitly delete session (same as default)
55
+ auggiegw --delete-session fetch
19
56
  ```
20
57
 
21
- Run linter:
58
+ **Precedence Order** (highest to lowest):
59
+ 1. Command-line flags (`--preserve-session` or `--delete-session`)
60
+ 2. Environment variable (`AUGGIEGW_DELETE_SESSION`)
61
+ 3. Default behavior (delete session)
62
+
63
+ ---
64
+
65
+ ## Commands
66
+
67
+ ### `auggiegw login [username] [password]`
68
+
69
+ Login and store credentials securely.
22
70
 
71
+ **Interactive Mode** (Recommended):
23
72
  ```bash
24
- bun run lint
73
+ auggiegw login
25
74
  ```
75
+ You'll be prompted to enter your username and password. The password input is hidden for security.
76
+
77
+ **Direct Mode**:
78
+ ```bash
79
+ auggiegw login myusername mypassword
80
+ ```
81
+
82
+ **What it does**:
83
+ - Authenticates with the Augment Gateway API
84
+ - Stores credentials in `~/.auggiegw/auth.json`
85
+ - Token is used for subsequent commands
86
+
87
+ ---
26
88
 
27
- Clean build artifacts:
89
+ ### `auggiegw logout`
90
+
91
+ Logout and remove stored credentials.
28
92
 
29
93
  ```bash
30
- bun run clean
94
+ auggiegw logout
31
95
  ```
32
96
 
33
- ## Usage
97
+ **What it does**:
98
+ - Deletes the authentication file (`~/.auggiegw/auth.json`)
99
+ - Removes stored credentials from your system
34
100
 
35
- ### Authentication
101
+ ---
36
102
 
37
- There are two ways to authenticate with auggiegw:
103
+ ### `auggiegw fetch`
38
104
 
39
- #### 1. Using Environment Variable (Recommended for CI/CD)
105
+ Fetch proxy configuration, authenticate, and download custom prompts.
40
106
 
41
- Set the `AUGGIEGW_AUTH_TOKEN` environment variable with your authentication token:
107
+ **Basic Usage**:
108
+ ```bash
109
+ auggiegw fetch
110
+ ```
42
111
 
112
+ **With Session Control**:
43
113
  ```bash
44
- export AUGGIEGW_AUTH_TOKEN=your_token_here
114
+ # Preserve chat history
115
+ auggiegw --preserve-session fetch
116
+
117
+ # Explicitly delete session (default)
118
+ auggiegw --delete-session fetch
45
119
  ```
46
120
 
47
- When this environment variable is set, the CLI will use it directly without requiring login or auth.json file.
121
+ **What it does**:
122
+ 1. Retrieves proxy configuration from Augment Gateway
123
+ 2. Authenticates the proxy
124
+ 3. Saves Augment session to `~/.augment/session.json`
125
+ 4. Deletes Auggie session (unless `--preserve-session` is used)
126
+ 5. Fetches all custom prompts from the server
127
+ 6. Saves prompts as markdown files in `~/.augment/commands/`
128
+
129
+ **Output Example**:
130
+ ```
131
+ ✔ Successfully saved 15 prompts
132
+ ```
48
133
 
49
- #### 2. Using Login Command
134
+ ---
50
135
 
51
- Login with your credentials:
136
+ ### `auggiegw auggie [args...]`
52
137
 
138
+ Forward commands to the Auggie CLI with automatic configuration.
139
+
140
+ **Basic Usage**:
53
141
  ```bash
54
- auggiegw login [username] [password]
142
+ auggiegw auggie [auggie-arguments]
55
143
  ```
56
144
 
57
- This will save your credentials to `~/.auggiegw/auth.json` for future use.
145
+ **Examples**:
146
+ ```bash
147
+ # Run Auggie with help
148
+ auggiegw auggie --help
149
+
150
+ # Run Auggie and preserve chat history
151
+ auggiegw --preserve-session auggie
152
+
153
+ # Run Auggie with a specific prompt
154
+ auggiegw --preserve-session auggie --print "Hello, world!"
155
+ ```
58
156
 
59
- ### CLI Commands
157
+ **What it does**:
158
+ 1. Runs `auggiegw fetch` to ensure configuration is up-to-date
159
+ 2. Deletes Auggie session (unless `--preserve-session` is used)
160
+ 3. Forwards all arguments to the `auggie` command
161
+ 4. Inherits stdio for interactive sessions
60
162
 
61
- #### Login
163
+ ---
164
+
165
+ ### `auggiegw exec <command> [args...]`
166
+
167
+ Execute any custom command with automatic session setup.
168
+
169
+ **Basic Usage**:
62
170
  ```bash
63
- auggiegw login [username] [password]
171
+ auggiegw exec <command> [arguments]
64
172
  ```
65
173
 
66
- #### Logout
174
+ **Examples**:
67
175
  ```bash
68
- auggiegw logout
176
+ # Execute auggie with help
177
+ auggiegw exec auggie --help
178
+
179
+ # Execute with preserved session
180
+ auggiegw --preserve-session exec auggie --help
181
+
182
+ # Execute custom command
183
+ auggiegw --preserve-session exec node script.js
184
+ ```
185
+
186
+ **What it does**:
187
+ 1. Runs `auggiegw fetch` to ensure configuration is up-to-date
188
+ 2. Deletes Auggie session (unless `--preserve-session` is used)
189
+ 3. Executes the specified command with provided arguments
190
+ 4. Inherits stdio for interactive sessions
191
+
192
+ ---
193
+
194
+ ## Authentication Methods
195
+
196
+ ### Method 1: Login Command (Recommended for Local Development)
197
+
198
+ ```bash
199
+ auggiegw login
200
+ ```
201
+
202
+ Credentials are stored in `~/.auggiegw/auth.json` and automatically used for subsequent commands.
203
+
204
+ ### Method 2: Environment Variable (Recommended for CI/CD)
205
+
206
+ Set the `AUGGIEGW_AUTH_TOKEN` environment variable:
207
+
208
+ ```bash
209
+ export AUGGIEGW_AUTH_TOKEN=your_token_here
210
+ ```
211
+
212
+ When this environment variable is set, the CLI uses it directly without requiring the login command or auth.json file.
213
+
214
+ **Example in CI/CD**:
215
+ ```yaml
216
+ # GitHub Actions example
217
+ env:
218
+ AUGGIEGW_AUTH_TOKEN: ${{ secrets.AUGGIEGW_AUTH_TOKEN }}
69
219
  ```
70
220
 
71
- #### Fetch proxy configuration and prompts
221
+ ---
222
+
223
+ ## Configuration
224
+
225
+ ### Session Management
226
+
227
+ The CLI provides multiple ways to control session deletion behavior when switching accounts:
228
+
229
+ #### 1. Command-Line Flags (Highest Priority)
230
+
231
+ Use global options with any command:
232
+
72
233
  ```bash
234
+ # Preserve session for a single command
235
+ auggiegw --preserve-session fetch
236
+
237
+ # Explicitly delete session (default behavior)
238
+ auggiegw --delete-session fetch
239
+ ```
240
+
241
+ #### 2. Environment Variable
242
+
243
+ Set `AUGGIEGW_DELETE_SESSION` to control default behavior:
244
+
245
+ ```bash
246
+ # Preserve sessions by default
247
+ export AUGGIEGW_DELETE_SESSION=false
73
248
  auggiegw fetch
249
+
250
+ # Delete sessions by default (same as built-in default)
251
+ export AUGGIEGW_DELETE_SESSION=true
252
+ auggiegw fetch
253
+ ```
254
+
255
+ #### 3. Default Behavior (Lowest Priority)
256
+
257
+ By default, the CLI deletes the Auggie session (including chat history) when fetching configuration to ensure a clean state for each account.
258
+
259
+ **Precedence Order**:
260
+ 1. **Command-line flags** (`--preserve-session` or `--delete-session`) - Always takes precedence
261
+ 2. **Environment variable** (`AUGGIEGW_DELETE_SESSION`) - Used if no CLI flag is provided
262
+ 3. **Default behavior** (delete session) - Used if neither flag nor environment variable is set
263
+
264
+ **Examples**:
265
+
266
+ ```bash
267
+ # CLI flag overrides environment variable
268
+ export AUGGIEGW_DELETE_SESSION=false
269
+ auggiegw --delete-session fetch # Session WILL be deleted
270
+
271
+ # Environment variable is used when no flag is provided
272
+ export AUGGIEGW_DELETE_SESSION=false
273
+ auggiegw fetch # Session will NOT be deleted
274
+
275
+ # Default behavior when nothing is set
276
+ unset AUGGIEGW_DELETE_SESSION
277
+ auggiegw fetch # Session WILL be deleted (default)
278
+ ```
279
+
280
+ ### Environment Variables
281
+
282
+ - **`AUGGIEGW_AUTH_TOKEN`**: Authentication token for API access (alternative to login command)
283
+ - **`AUGGIEGW_DELETE_SESSION`**: Control Auggie session deletion behavior
284
+ - Set to `false` to preserve chat history when switching accounts
285
+ - Set to `true` or leave unset for default behavior (delete session)
286
+ - Can be overridden by command-line flags
287
+
288
+ ### File Locations
289
+
290
+ - **Auth Data**: `~/.auggiegw/auth.json`
291
+ - **Augment Session**: `~/.augment/session.json`
292
+ - **Custom Prompts**: `~/.augment/commands/*.md`
293
+
294
+ ---
295
+
296
+ ## Custom Prompts
297
+
298
+ Custom prompts are fetched from the Augment Gateway and saved as markdown files in `~/.augment/commands/`. Each prompt file follows this format:
299
+
300
+ ```markdown
301
+ ---
302
+ description: Prompt Name
303
+ ---
304
+
305
+ Prompt content goes here...
74
306
  ```
75
307
 
76
- #### Forward command to auggie CLI
308
+ The filename corresponds to the command name (e.g., `my-command.md`).
309
+
310
+ ---
311
+
312
+ ## Usage Examples
313
+
314
+ ### Switching Accounts with Preserved Chat History
315
+
77
316
  ```bash
78
- auggiegw auggie [args...]
317
+ # Method 1: Using command-line flag
318
+ auggiegw login user1
319
+ auggiegw --preserve-session fetch
320
+ auggiegw --preserve-session auggie
321
+
322
+ # Switch to another account
323
+ auggiegw login user2
324
+ auggiegw --preserve-session fetch
325
+ auggiegw --preserve-session auggie
79
326
  ```
80
327
 
81
- #### Execute custom command
328
+ ### Switching Accounts with Clean Sessions (Default)
329
+
82
330
  ```bash
83
- auggiegw exec <command> [args...]
331
+ # Default behavior - session is deleted
332
+ auggiegw login user1
333
+ auggiegw fetch
334
+ auggiegw auggie
335
+
336
+ # Switch to another account - previous session is cleared
337
+ auggiegw login user2
338
+ auggiegw fetch
339
+ auggiegw auggie
84
340
  ```
85
341
 
86
- ### As a library
342
+ ### Using Environment Variable for Multiple Commands
87
343
 
88
- Import and use in your Node.js project:
344
+ ```bash
345
+ # Set environment variable once
346
+ export AUGGIEGW_DELETE_SESSION=false
347
+
348
+ # All subsequent commands preserve session
349
+ auggiegw login user1
350
+ auggiegw fetch
351
+ auggiegw auggie
89
352
 
90
- ```typescript
91
- import '@dccxx/auggiegw';
353
+ # Switch accounts without losing history
354
+ auggiegw login user2
355
+ auggiegw fetch
356
+ auggiegw auggie
92
357
  ```
93
358
 
94
- ## Project Structure
359
+ ### Override Environment Variable with CLI Flag
95
360
 
96
- - `src/` - TypeScript source files
97
- - `dist/` - Compiled JavaScript output (generated by build)
98
- - `tsconfig.json` - TypeScript configuration
99
- - `biome.json` - Biome linter configuration
361
+ ```bash
362
+ # Set default to preserve
363
+ export AUGGIEGW_DELETE_SESSION=false
364
+
365
+ # This preserves session (follows env var)
366
+ auggiegw fetch
367
+
368
+ # This deletes session (CLI flag overrides env var)
369
+ auggiegw --delete-session fetch
370
+ ```
371
+
372
+ ### CI/CD Pipeline Example
373
+
374
+ ```yaml
375
+ # GitHub Actions workflow
376
+ jobs:
377
+ deploy:
378
+ runs-on: ubuntu-latest
379
+ steps:
380
+ - name: Setup authentication
381
+ env:
382
+ AUGGIEGW_AUTH_TOKEN: ${{ secrets.AUGGIEGW_AUTH_TOKEN }}
383
+ AUGGIEGW_DELETE_SESSION: true
384
+ run: |
385
+ auggiegw fetch
386
+ auggiegw exec npm run deploy
387
+ ```
388
+
389
+ ---
100
390
 
101
391
  ## Requirements
102
392
 
103
- - Node.js >= 18.0.0
104
- - Bun (for package management and running scripts)
393
+ - **Node.js**: >= 18.0.0
394
+ - **Bun**: For package management and running scripts (development)
395
+ - **Auggie CLI**: Required for `auggiegw auggie` command
396
+
397
+ ---
398
+
399
+ ## Troubleshooting
400
+
401
+ ### "Not logged in" Error
402
+
403
+ ```
404
+ Error: Not logged in. Please run "auggiegw login" first.
405
+ ```
406
+
407
+ **Solution**: Run `auggiegw login` to authenticate.
408
+
409
+ ### "Failed to get proxy" Error
410
+
411
+ **Possible causes**:
412
+ - Invalid credentials
413
+ - Network connectivity issues
414
+ - API endpoint unavailable
415
+
416
+ **Solution**:
417
+ 1. Verify your credentials with `auggiegw logout` then `auggiegw login`
418
+ 2. Check your network connection
419
+ 3. Verify the API URL is correct
420
+
421
+ ### "No proxy data available" Error
422
+
423
+ **Solution**: Contact your administrator to ensure your account has proxy access configured.
424
+
425
+ ### Chat History Lost When Switching Accounts
426
+
427
+ By default, the CLI deletes the Auggie session (including chat history) when fetching configuration. This ensures a clean state for each account.
428
+
429
+ **Solution 1: Use Command-Line Flag (Recommended)**
430
+
431
+ Preserve session for specific commands:
432
+
433
+ ```bash
434
+ # Login to new account
435
+ auggiegw login newuser
436
+
437
+ # Fetch with preserved session
438
+ auggiegw --preserve-session fetch
439
+
440
+ # Or use with auggie command
441
+ auggiegw --preserve-session auggie
442
+ ```
443
+
444
+ **Solution 2: Use Environment Variable**
445
+
446
+ Set a persistent default behavior:
447
+
448
+ ```bash
449
+ # Set the environment variable to disable session deletion
450
+ export AUGGIEGW_DELETE_SESSION=false
451
+
452
+ # Then run your commands as usual
453
+ auggiegw login newuser
454
+ auggiegw fetch
455
+ ```
456
+
457
+ **Solution 3: Mixed Approach**
458
+
459
+ Combine both methods for flexibility:
460
+
461
+ ```bash
462
+ # Set default to preserve
463
+ export AUGGIEGW_DELETE_SESSION=false
464
+
465
+ # Most commands will preserve session
466
+ auggiegw fetch
467
+
468
+ # But you can override for specific commands
469
+ auggiegw --delete-session fetch # This will delete the session
470
+ ```
471
+
472
+ **Note**: Disabling session deletion may cause conflicts if different accounts have incompatible session data. Use this option only if you need to preserve chat history across account switches.
473
+
474
+ ---
475
+
476
+ ## License
477
+
478
+ See LICENSE file for details.
479
+
480
+ ## Support
481
+
482
+ For issues and questions, please open an issue on the GitHub repository.
483
+
package/dist/cli.js CHANGED
@@ -19,6 +19,29 @@ function loadConfig() {
19
19
  const apiUrl = process.env.AUGMENT_GATEWAY_URL || 'https://augmentgateway.1app.space';
20
20
  return { apiUrl };
21
21
  }
22
+ function getSessionOptions(opts) {
23
+ const sessionOptions = {};
24
+ // CLI flags take precedence
25
+ if (opts.preserveSession) {
26
+ sessionOptions.deleteSession = false;
27
+ }
28
+ else if (opts.deleteSession) {
29
+ sessionOptions.deleteSession = true;
30
+ }
31
+ return sessionOptions;
32
+ }
33
+ function shouldDeleteSession(options) {
34
+ // Priority: CLI flag > Environment variable > Default (true)
35
+ if (options?.deleteSession !== undefined) {
36
+ return options.deleteSession;
37
+ }
38
+ // Check environment variable
39
+ if (process.env.AUGGIEGW_DELETE_SESSION !== undefined) {
40
+ return process.env.AUGGIEGW_DELETE_SESSION !== 'false';
41
+ }
42
+ // Default behavior: delete session
43
+ return true;
44
+ }
22
45
  async function ensureAuthDirectory() {
23
46
  try {
24
47
  await fs.mkdir(AUTH_DIR, { recursive: true });
@@ -250,7 +273,7 @@ async function handleLogout() {
250
273
  process.exit(1);
251
274
  }
252
275
  }
253
- async function handleFetch() {
276
+ async function handleFetch(options) {
254
277
  const spinner = ora('Initializing...').start();
255
278
  try {
256
279
  const config = loadConfig();
@@ -283,11 +306,14 @@ async function handleFetch() {
283
306
  scopes: ['read', 'write'],
284
307
  };
285
308
  await saveAugmentSession(augmentSession);
286
- try {
287
- await execAsync('auggie session delete');
288
- }
289
- catch {
290
- // Silently ignore auggie session delete errors
309
+ // Check if session deletion is enabled
310
+ if (shouldDeleteSession(options)) {
311
+ try {
312
+ await execAsync('auggie session delete');
313
+ }
314
+ catch {
315
+ // Silently ignore auggie session delete errors
316
+ }
291
317
  }
292
318
  spinner.text = 'Fetching prompts...';
293
319
  const allPrompts = await getAllPrompts(token, config.apiUrl, spinner);
@@ -308,8 +334,8 @@ async function handleFetch() {
308
334
  process.exit(1);
309
335
  }
310
336
  }
311
- async function handleAuggie(args) {
312
- await handleFetch();
337
+ async function handleAuggie(args, options) {
338
+ await handleFetch(options);
313
339
  const auggieProcess = spawn('auggie', args, {
314
340
  stdio: 'inherit',
315
341
  shell: true,
@@ -322,13 +348,13 @@ async function handleAuggie(args) {
322
348
  process.exit(code ?? 0);
323
349
  });
324
350
  }
325
- async function handleExec(command, args) {
351
+ async function handleExec(command, args, options) {
326
352
  if (!command) {
327
353
  console.error('Error: Command is required');
328
354
  console.error('Usage: auggiegw exec <command> [args...]');
329
355
  process.exit(1);
330
356
  }
331
- await handleFetch();
357
+ await handleFetch(options);
332
358
  const childProcess = spawn(command, args, {
333
359
  stdio: 'inherit',
334
360
  shell: true,
@@ -342,7 +368,12 @@ async function handleExec(command, args) {
342
368
  });
343
369
  }
344
370
  const program = new Command();
345
- program.name('auggiegw').description('CLI tool for auggiegw authentication').version('1.0.0');
371
+ program
372
+ .name('auggiegw')
373
+ .description('CLI tool for auggiegw authentication')
374
+ .version('1.0.0')
375
+ .option('--preserve-session', 'Preserve Auggie session (do not delete chat history)')
376
+ .option('--delete-session', 'Delete Auggie session (clear chat history)');
346
377
  program
347
378
  .command('login [username] [password]')
348
379
  .description('Login and store credentials')
@@ -351,20 +382,28 @@ program.command('logout').description('Logout and remove stored credentials').ac
351
382
  program
352
383
  .command('fetch')
353
384
  .description('Fetch proxy configuration and authenticate')
354
- .action(handleFetch);
385
+ .action(() => {
386
+ const opts = program.opts();
387
+ const sessionOptions = getSessionOptions(opts);
388
+ handleFetch(sessionOptions);
389
+ });
355
390
  program
356
391
  .command('auggie [args...]')
357
392
  .description('Forward command to auggie CLI')
358
393
  .allowUnknownOption()
359
394
  .action((args) => {
360
- handleAuggie(args || []);
395
+ const opts = program.opts();
396
+ const sessionOptions = getSessionOptions(opts);
397
+ handleAuggie(args || [], sessionOptions);
361
398
  });
362
399
  program
363
400
  .command('exec <command> [args...]')
364
401
  .description('Execute any custom command')
365
402
  .allowUnknownOption()
366
403
  .action((command, args) => {
367
- handleExec(command, args);
404
+ const opts = program.opts();
405
+ const sessionOptions = getSessionOptions(opts);
406
+ handleExec(command, args, sessionOptions);
368
407
  });
369
408
  program.parse();
370
409
  //# sourceMappingURL=cli.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dccxx/auggiegw",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "A Node.js TypeScript package",
5
5
  "main": "./dist/cli.js",
6
6
  "types": "./dist/cli.d.ts",