@dccxx/auggiegw 1.0.4 → 1.0.6

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
@@ -1,67 +1,238 @@
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
26
+
27
+ 1. **Login to Augment Gateway**:
28
+ ```bash
29
+ auggiegw login
30
+ ```
31
+ You'll be prompted for your username and password.
32
+
33
+ 2. **Fetch Configuration**:
34
+ ```bash
35
+ auggiegw fetch
36
+ ```
37
+ This fetches proxy configuration, authenticates, and downloads custom prompts.
38
+
39
+ ## Commands
40
+
41
+ ### `auggiegw login [username] [password]`
14
42
 
15
- Build the project:
43
+ Login and store credentials securely.
16
44
 
45
+ **Interactive Mode** (Recommended):
17
46
  ```bash
18
- bun run build
47
+ auggiegw login
19
48
  ```
49
+ You'll be prompted to enter your username and password. The password input is hidden for security.
20
50
 
21
- Run linter:
51
+ **Direct Mode**:
52
+ ```bash
53
+ auggiegw login myusername mypassword
54
+ ```
55
+
56
+ **What it does**:
57
+ - Authenticates with the Augment Gateway API
58
+ - Stores credentials in `~/.auggiegw/auth.json`
59
+ - Token is used for subsequent commands
60
+
61
+ ---
62
+
63
+ ### `auggiegw logout`
64
+
65
+ Logout and remove stored credentials.
22
66
 
23
67
  ```bash
24
- bun run lint
68
+ auggiegw logout
25
69
  ```
26
70
 
27
- Clean build artifacts:
71
+ **What it does**:
72
+ - Deletes the authentication file (`~/.auggiegw/auth.json`)
73
+ - Removes stored credentials from your system
74
+
75
+ ---
76
+
77
+ ### `auggiegw fetch`
78
+
79
+ Fetch proxy configuration, authenticate, and download custom prompts.
28
80
 
29
81
  ```bash
30
- bun run clean
82
+ auggiegw fetch
31
83
  ```
32
84
 
33
- ## Usage
85
+ **What it does**:
86
+ 1. Retrieves proxy configuration from Augment Gateway
87
+ 2. Authenticates the proxy
88
+ 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/`
34
91
 
35
- ### As a CLI tool
92
+ **Output Example**:
93
+ ```
94
+ ✔ Successfully saved 15 prompts
95
+ ```
96
+
97
+ ---
36
98
 
37
- After building, you can run the CLI command:
99
+ ### `auggiegw auggie [args...]`
100
+
101
+ Forward commands to the Auggie CLI with automatic configuration.
38
102
 
39
103
  ```bash
40
- node dist/cli.js
104
+ auggiegw auggie [auggie-arguments]
41
105
  ```
42
106
 
43
- Or if installed globally:
107
+ **Examples**:
108
+ ```bash
109
+ # Run Auggie with help
110
+ auggiegw auggie --help
111
+ ```
112
+
113
+ **What it does**:
114
+ 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
117
+
118
+ ---
119
+
120
+ ### `auggiegw exec <command> [args...]`
121
+
122
+ Execute any custom command with automatic session setup.
44
123
 
45
124
  ```bash
46
- auggiegw
125
+ auggiegw exec <command> [arguments]
47
126
  ```
48
127
 
49
- ### As a library
128
+ **Examples**:
129
+ ```bash
130
+ auggiegw exec auggie --help
131
+ ```
132
+
133
+ **What it does**:
134
+ 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
137
+
138
+ ---
50
139
 
51
- Import and use in your Node.js project:
140
+ ## Authentication Methods
52
141
 
53
- ```typescript
54
- import '@dccxx/auggiegw';
142
+ ### Method 1: Login Command (Recommended for Local Development)
143
+
144
+ ```bash
145
+ auggiegw login
55
146
  ```
56
147
 
57
- ## Project Structure
148
+ Credentials are stored in `~/.auggiegw/auth.json` and automatically used for subsequent commands.
58
149
 
59
- - `src/` - TypeScript source files
60
- - `dist/` - Compiled JavaScript output (generated by build)
61
- - `tsconfig.json` - TypeScript configuration
62
- - `biome.json` - Biome linter configuration
150
+ ### Method 2: Environment Variable (Recommended for CI/CD)
151
+
152
+ Set the `AUGGIEGW_AUTH_TOKEN` environment variable:
153
+
154
+ ```bash
155
+ export AUGGIEGW_AUTH_TOKEN=your_token_here
156
+ ```
157
+
158
+ When this environment variable is set, the CLI uses it directly without requiring the login command or auth.json file.
159
+
160
+ **Example in CI/CD**:
161
+ ```yaml
162
+ # GitHub Actions example
163
+ env:
164
+ AUGGIEGW_AUTH_TOKEN: ${{ secrets.AUGGIEGW_AUTH_TOKEN }}
165
+ ```
166
+
167
+ ---
168
+
169
+ ## Configuration
170
+
171
+ ### File Locations
172
+
173
+ - **Auth Data**: `~/.auggiegw/auth.json`
174
+ - **Augment Session**: `~/.augment/session.json`
175
+ - **Custom Prompts**: `~/.augment/commands/*.md`
176
+
177
+ ---
178
+
179
+ ## Custom Prompts
180
+
181
+ Custom prompts are fetched from the Augment Gateway and saved as markdown files in `~/.augment/commands/`. Each prompt file follows this format:
182
+
183
+ ```markdown
184
+ ---
185
+ description: Prompt Name
186
+ ---
187
+
188
+ Prompt content goes here...
189
+ ```
190
+
191
+ The filename corresponds to the command name (e.g., `my-command.md`).
192
+
193
+ ---
63
194
 
64
195
  ## Requirements
65
196
 
66
- - Node.js >= 18.0.0
67
- - Bun (for package management and running scripts)
197
+ - **Node.js**: >= 18.0.0
198
+ - **Bun**: For package management and running scripts (development)
199
+ - **Auggie CLI**: Required for `auggiegw auggie` command
200
+
201
+ ---
202
+
203
+ ## Troubleshooting
204
+
205
+ ### "Not logged in" Error
206
+
207
+ ```
208
+ Error: Not logged in. Please run "auggiegw login" first.
209
+ ```
210
+
211
+ **Solution**: Run `auggiegw login` to authenticate.
212
+
213
+ ### "Failed to get proxy" Error
214
+
215
+ **Possible causes**:
216
+ - Invalid credentials
217
+ - Network connectivity issues
218
+ - API endpoint unavailable
219
+
220
+ **Solution**:
221
+ 1. Verify your credentials with `auggiegw logout` then `auggiegw login`
222
+ 2. Check your network connection
223
+ 3. Verify the API URL is correct
224
+
225
+ ### "No proxy data available" Error
226
+
227
+ **Solution**: Contact your administrator to ensure your account has proxy access configured.
228
+
229
+ ---
230
+
231
+ ## License
232
+
233
+ See LICENSE file for details.
234
+
235
+ ## Support
236
+
237
+ For issues and questions, please open an issue on the GitHub repository.
238
+
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.6",
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
+ }