@dccxx/auggiegw 1.0.6 → 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 +251 -6
  2. package/dist/cli.js +53 -14
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -36,6 +36,32 @@ bun install -g @dccxx/auggiegw
36
36
  ```
37
37
  This fetches proxy configuration, authenticates, and downloads custom prompts.
38
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**:
47
+ ```bash
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
56
+ ```
57
+
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
+
39
65
  ## Commands
40
66
 
41
67
  ### `auggiegw login [username] [password]`
@@ -78,16 +104,27 @@ auggiegw logout
78
104
 
79
105
  Fetch proxy configuration, authenticate, and download custom prompts.
80
106
 
107
+ **Basic Usage**:
81
108
  ```bash
82
109
  auggiegw fetch
83
110
  ```
84
111
 
112
+ **With Session Control**:
113
+ ```bash
114
+ # Preserve chat history
115
+ auggiegw --preserve-session fetch
116
+
117
+ # Explicitly delete session (default)
118
+ auggiegw --delete-session fetch
119
+ ```
120
+
85
121
  **What it does**:
86
122
  1. Retrieves proxy configuration from Augment Gateway
87
123
  2. Authenticates the proxy
88
124
  3. Saves Augment session to `~/.augment/session.json`
89
- 4. Fetches all custom prompts from the server
90
- 5. Saves prompts as markdown files in `~/.augment/commands/`
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/`
91
128
 
92
129
  **Output Example**:
93
130
  ```
@@ -100,6 +137,7 @@ auggiegw fetch
100
137
 
101
138
  Forward commands to the Auggie CLI with automatic configuration.
102
139
 
140
+ **Basic Usage**:
103
141
  ```bash
104
142
  auggiegw auggie [auggie-arguments]
105
143
  ```
@@ -108,12 +146,19 @@ auggiegw auggie [auggie-arguments]
108
146
  ```bash
109
147
  # Run Auggie with help
110
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!"
111
155
  ```
112
156
 
113
157
  **What it does**:
114
158
  1. Runs `auggiegw fetch` to ensure configuration is up-to-date
115
- 2. Forwards all arguments to the `auggie` command
116
- 3. Inherits stdio for interactive sessions
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
117
162
 
118
163
  ---
119
164
 
@@ -121,19 +166,28 @@ auggiegw auggie --help
121
166
 
122
167
  Execute any custom command with automatic session setup.
123
168
 
169
+ **Basic Usage**:
124
170
  ```bash
125
171
  auggiegw exec <command> [arguments]
126
172
  ```
127
173
 
128
174
  **Examples**:
129
175
  ```bash
176
+ # Execute auggie with help
130
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
131
184
  ```
132
185
 
133
186
  **What it does**:
134
187
  1. Runs `auggiegw fetch` to ensure configuration is up-to-date
135
- 2. Executes the specified command with provided arguments
136
- 3. Inherits stdio for interactive sessions
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
137
191
 
138
192
  ---
139
193
 
@@ -168,6 +222,69 @@ env:
168
222
 
169
223
  ## Configuration
170
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
+
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
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
+
171
288
  ### File Locations
172
289
 
173
290
  - **Auth Data**: `~/.auggiegw/auth.json`
@@ -192,6 +309,85 @@ The filename corresponds to the command name (e.g., `my-command.md`).
192
309
 
193
310
  ---
194
311
 
312
+ ## Usage Examples
313
+
314
+ ### Switching Accounts with Preserved Chat History
315
+
316
+ ```bash
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
326
+ ```
327
+
328
+ ### Switching Accounts with Clean Sessions (Default)
329
+
330
+ ```bash
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
340
+ ```
341
+
342
+ ### Using Environment Variable for Multiple Commands
343
+
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
352
+
353
+ # Switch accounts without losing history
354
+ auggiegw login user2
355
+ auggiegw fetch
356
+ auggiegw auggie
357
+ ```
358
+
359
+ ### Override Environment Variable with CLI Flag
360
+
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
+ ---
390
+
195
391
  ## Requirements
196
392
 
197
393
  - **Node.js**: >= 18.0.0
@@ -226,6 +422,55 @@ Error: Not logged in. Please run "auggiegw login" first.
226
422
 
227
423
  **Solution**: Contact your administrator to ensure your account has proxy access configured.
228
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
+
229
474
  ---
230
475
 
231
476
  ## License
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.6",
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",