@dccxx/auggiegw 1.0.18 → 1.0.20
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/CLAUDE.md +148 -0
- package/auggie_shell_conversation.txt +96 -0
- package/auggie_shell_user_request.txt +23 -0
- package/auggiegw/https---d16.api.augmentcode.com-get-credit-info.bru +32 -0
- package/dist/cli.js +2625 -426
- package/justfile +5 -4
- package/package.json +6 -3
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
`@dccxx/auggiegw` is a CLI tool for managing Augment Gateway authentication, proxy configuration, and custom prompts. It authenticates with Augment Gateway, fetches proxy configurations, manages custom prompts, and integrates with the Auggie CLI.
|
|
8
|
+
|
|
9
|
+
## Build & Development Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Install dependencies
|
|
13
|
+
bun install
|
|
14
|
+
|
|
15
|
+
# Build TypeScript to dist/ (uses Bun's native build with Node.js target)
|
|
16
|
+
bun run build
|
|
17
|
+
|
|
18
|
+
# Lint with Biome (auto-fix enabled)
|
|
19
|
+
bun run lint
|
|
20
|
+
|
|
21
|
+
# Clean dist directory
|
|
22
|
+
bun run clean
|
|
23
|
+
|
|
24
|
+
# Development: run CLI commands directly
|
|
25
|
+
bun run src/cli.ts login
|
|
26
|
+
bun run src/cli.ts fetch
|
|
27
|
+
bun run src/cli.ts auggie --print "hi"
|
|
28
|
+
|
|
29
|
+
# Publish workflow (bumps version, lints, builds, publishes)
|
|
30
|
+
bun run publish:auto
|
|
31
|
+
# Or using justfile:
|
|
32
|
+
just release
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Package Manager
|
|
36
|
+
|
|
37
|
+
**ALWAYS use Bun** - never npm, yarn, or pnpm.
|
|
38
|
+
|
|
39
|
+
## Architecture
|
|
40
|
+
|
|
41
|
+
Single-file CLI application (`src/cli.ts`) using Commander.js. All logic is contained in one file with clear separation:
|
|
42
|
+
|
|
43
|
+
1. **Type Definitions** (lines 18-139): All interfaces for API responses and internal data structures
|
|
44
|
+
2. **Constants** (lines 141-145): File paths for auth and session storage
|
|
45
|
+
3. **Utility Functions** (lines 147-227): Config loading, auth data management
|
|
46
|
+
4. **API Functions** (lines 238-472): HTTP calls to Augment Gateway API
|
|
47
|
+
5. **Command Handlers** (lines 474-770): Business logic for each CLI command
|
|
48
|
+
6. **CLI Setup** (lines 772-823): Commander.js program definition
|
|
49
|
+
|
|
50
|
+
### Key File Locations
|
|
51
|
+
|
|
52
|
+
- Auth credentials: `~/.auggiegw/auth.json`
|
|
53
|
+
- Augment session: `~/.augment/session.json`
|
|
54
|
+
- Custom prompts: `~/.augment/commands/*.md`
|
|
55
|
+
- Auggie sessions: `~/.augment/sessions/*.json`
|
|
56
|
+
|
|
57
|
+
## Special Logic & Non-Obvious Implementations
|
|
58
|
+
|
|
59
|
+
### Proxy Password Parsing (lines 544-550)
|
|
60
|
+
|
|
61
|
+
The proxy password contains an `@` symbol as a delimiter. The actual password is extracted by taking everything before the first `@`:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
const atIndex = rawPassword.indexOf('@');
|
|
65
|
+
const proxyPassword = rawPassword.substring(0, atIndex);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Session Deletion Logic (lines 564-639)
|
|
69
|
+
|
|
70
|
+
When `shouldDeleteSession()` returns true, the code performs a complex session reset:
|
|
71
|
+
|
|
72
|
+
1. Reads all JSON files from `~/.augment/sessions/`
|
|
73
|
+
2. Sorts by modification time (most recent first)
|
|
74
|
+
3. Deletes all files except the most recent
|
|
75
|
+
4. For the most recent file:
|
|
76
|
+
- Generates a new UUID for `sessionId`
|
|
77
|
+
- Replaces all `"request_id"` keys with `"request_id_temp"` (invalidates old requests)
|
|
78
|
+
- Saves with new filename matching the new UUID
|
|
79
|
+
- Deletes the old file
|
|
80
|
+
|
|
81
|
+
If this fails, falls back to `auggie session delete` command.
|
|
82
|
+
|
|
83
|
+
### Session Options Priority (lines 169-182)
|
|
84
|
+
|
|
85
|
+
Session deletion follows this precedence:
|
|
86
|
+
1. CLI flags (`--preserve-session` / `--delete-session`)
|
|
87
|
+
2. Environment variable `AUGGIEGW_DELETE_SESSION`
|
|
88
|
+
3. Default: delete session (true)
|
|
89
|
+
|
|
90
|
+
### Refresh Commands Logic (--refresh-commands flag)
|
|
91
|
+
|
|
92
|
+
When `--refresh-commands` is provided:
|
|
93
|
+
1. Deletes all existing `.md` files in `~/.augment/commands/`
|
|
94
|
+
2. Fetches all prompts from the API using `getAllPrompts()`
|
|
95
|
+
3. Saves the fetched prompts to `~/.augment/commands/`
|
|
96
|
+
|
|
97
|
+
When `--refresh-commands` is NOT provided (default):
|
|
98
|
+
- Skips prompt fetching entirely for faster operation
|
|
99
|
+
- Only performs authentication
|
|
100
|
+
|
|
101
|
+
The `--auth-only` flag takes precedence over `--refresh-commands` (if both are provided, prompts are skipped).
|
|
102
|
+
|
|
103
|
+
### Account Switching Logic (lines 714-770)
|
|
104
|
+
|
|
105
|
+
The `switch-account` command:
|
|
106
|
+
- Fetches accounts sorted by `purchased_at` descending (newest first)
|
|
107
|
+
- Finds current account (status "in-use")
|
|
108
|
+
- Switches to the account at index `currentIndex - 1` (the newer one)
|
|
109
|
+
- After switching, calls `handleFetch({ authOnly: true, deleteSession: true })`
|
|
110
|
+
|
|
111
|
+
### Prompt File Format (lines 305-319)
|
|
112
|
+
|
|
113
|
+
Prompts are saved as markdown with YAML frontmatter:
|
|
114
|
+
|
|
115
|
+
```markdown
|
|
116
|
+
---
|
|
117
|
+
description: {prompt.name}
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
{prompt.content}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Authentication Token Resolution (lines 197-205)
|
|
124
|
+
|
|
125
|
+
`getAuthToken()` checks environment variable `AUGGIEGW_AUTH_TOKEN` first, then falls back to reading from `~/.auggiegw/auth.json`.
|
|
126
|
+
|
|
127
|
+
### Paginated Prompt Fetching (lines 264-303)
|
|
128
|
+
|
|
129
|
+
`getAllPrompts()` fetches prompts page by page (limit=10) with 500ms delay between requests to avoid rate limiting.
|
|
130
|
+
|
|
131
|
+
## Environment Variables
|
|
132
|
+
|
|
133
|
+
- `AUGMENT_GATEWAY_URL`: API base URL (default: `https://augmentgateway.1app.space`)
|
|
134
|
+
- `AUGGIEGW_AUTH_TOKEN`: Auth token (bypasses login requirement)
|
|
135
|
+
- `AUGGIEGW_DELETE_SESSION`: Control session deletion (`false` to preserve)
|
|
136
|
+
|
|
137
|
+
## Quality Assurance
|
|
138
|
+
|
|
139
|
+
After any code changes:
|
|
140
|
+
1. Run `bun run lint` - Biome linter, never use `--unsafe`
|
|
141
|
+
2. Run `bun run build` - Uses Bun's native bundler with Node.js target + tsc for type declarations
|
|
142
|
+
|
|
143
|
+
## Protected Files
|
|
144
|
+
|
|
145
|
+
Never edit:
|
|
146
|
+
- `*.http` files
|
|
147
|
+
- Files in `.idea/` directory
|
|
148
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
================================================================================
|
|
2
|
+
[2025-11-27T21:14:57.407Z]
|
|
3
|
+
Refactor the delete session logic in `src/cli.ts` at lines 564-570. Currently it calls `auggie session delete` command, but we need a completely new implementation.
|
|
4
|
+
|
|
5
|
+
**New Logic Requirements:**
|
|
6
|
+
|
|
7
|
+
1. Read all JSON files from the directory: `~\.augment\sessions` (use os.homedir() to get home directory)
|
|
8
|
+
|
|
9
|
+
2. Sort files by their modified time (use fs.stat or similar to get mtime)
|
|
10
|
+
|
|
11
|
+
3. Delete ALL files EXCEPT the most recently modified one
|
|
12
|
+
|
|
13
|
+
4. For the most recently modified file that is kept:
|
|
14
|
+
- Generate a new random UUID v4
|
|
15
|
+
- Update the `sessionId` field inside the JSON content to this new UUID
|
|
16
|
+
- Replace ALL occurrences of the key `"request_id"` with `"request_id_temp"` by:
|
|
17
|
+
- Converting JSON to string
|
|
18
|
+
- Using string replace (text replacement)
|
|
19
|
+
- Converting back to JSON
|
|
20
|
+
- Rename the file to match the new UUID (e.g., `{new-uuid}.json`)
|
|
21
|
+
|
|
22
|
+
**Example:**
|
|
23
|
+
If there are files:
|
|
24
|
+
- `C:\Users\0x317\.augment\sessions\3ac2b36f-7328-444a-a1ec-a1d5cb81c0f1.json`
|
|
25
|
+
- `C:\Users\0x317\.augment\sessions\3ac2b36f-7328-444a-a1ec-a1d5cb81c0f2.json`
|
|
26
|
+
|
|
27
|
+
Keep only the most recently modified one, change its sessionId to a new UUID, replace all "request_id" keys with "request_id_temp", and rename the file to the new UUID.
|
|
28
|
+
|
|
29
|
+
Make sure to:
|
|
30
|
+
- Use the `uuid` package for generating UUID v4 (check if already imported, if not add it)
|
|
31
|
+
- Handle edge cases (no files, only one file, directory doesn't exist)
|
|
32
|
+
- Keep the try-catch wrapper for silent error handling
|
|
33
|
+
- Use async/await properly with fs/promises
|
|
34
|
+
|
|
35
|
+
After implementation, run `bun run lint` and `bun run build` to verify the code quality and build.
|
|
36
|
+
|
|
37
|
+
Do not create or modify any markdown document files or code examples.
|
|
38
|
+
|
|
39
|
+
================================================================================
|
|
40
|
+
[2025-11-27T21:18:39.385Z]
|
|
41
|
+
In `src/cli.ts`, modify the catch block at lines 629-631 to add a fallback to the old logic.
|
|
42
|
+
|
|
43
|
+
Currently:
|
|
44
|
+
```
|
|
45
|
+
} catch {
|
|
46
|
+
// Silently ignore session management errors
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Change it to:
|
|
51
|
+
```
|
|
52
|
+
} catch {
|
|
53
|
+
// Fallback to old logic if new session management fails
|
|
54
|
+
try {
|
|
55
|
+
await execAsync('auggie session delete');
|
|
56
|
+
} catch {
|
|
57
|
+
// Silently ignore fallback errors
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This requires re-adding the `execAsync` utility that was previously removed. Add back:
|
|
63
|
+
- Import `exec` from `node:child_process`
|
|
64
|
+
- Import `promisify` from `node:util`
|
|
65
|
+
- Create `const execAsync = promisify(exec);`
|
|
66
|
+
|
|
67
|
+
After changes, run `bun run lint` and `bun run build` to verify.
|
|
68
|
+
|
|
69
|
+
Do not create or modify any markdown document files or code examples.
|
|
70
|
+
|
|
71
|
+
================================================================================
|
|
72
|
+
[2025-11-27T21:21:34.938Z]
|
|
73
|
+
Revert the delete session logic in `src/cli.ts` back to the original simple implementation.
|
|
74
|
+
|
|
75
|
+
The current implementation (around lines 564-635) has complex logic for reading session files, sorting by mtime, etc.
|
|
76
|
+
|
|
77
|
+
Revert it back to the original simple code:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
if (shouldDeleteSession(options)) {
|
|
81
|
+
try {
|
|
82
|
+
await execAsync('auggie session delete');
|
|
83
|
+
} catch {
|
|
84
|
+
// Silently ignore auggie session delete errors
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Also:
|
|
90
|
+
- Remove the `uuid` import (`import { v4 as uuidv4 } from 'uuid';`) since it's no longer needed
|
|
91
|
+
- Keep the `exec`, `promisify`, and `execAsync` since they are needed for the original logic
|
|
92
|
+
|
|
93
|
+
After changes, run `bun run lint` and `bun run build` to verify.
|
|
94
|
+
|
|
95
|
+
Do not create or modify any markdown document files or code examples.
|
|
96
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Revert the delete session logic in `src/cli.ts` back to the original simple implementation.
|
|
2
|
+
|
|
3
|
+
The current implementation (around lines 564-635) has complex logic for reading session files, sorting by mtime, etc.
|
|
4
|
+
|
|
5
|
+
Revert it back to the original simple code:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
if (shouldDeleteSession(options)) {
|
|
9
|
+
try {
|
|
10
|
+
await execAsync('auggie session delete');
|
|
11
|
+
} catch {
|
|
12
|
+
// Silently ignore auggie session delete errors
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Also:
|
|
18
|
+
- Remove the `uuid` import (`import { v4 as uuidv4 } from 'uuid';`) since it's no longer needed
|
|
19
|
+
- Keep the `exec`, `promisify`, and `execAsync` since they are needed for the original logic
|
|
20
|
+
|
|
21
|
+
After changes, run `bun run lint` and `bun run build` to verify.
|
|
22
|
+
|
|
23
|
+
Do not create or modify any markdown document files or code examples.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
meta {
|
|
2
|
+
name: https://d16.api.augmentcode.com/get-credit-info
|
|
3
|
+
type: http
|
|
4
|
+
seq: 3
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
post {
|
|
8
|
+
url: https://0.dathttps//d16.api.augmentcode.com/get-credit-info
|
|
9
|
+
body: none
|
|
10
|
+
auth: inherit
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
headers {
|
|
14
|
+
host: d16.api.augmentcode.com
|
|
15
|
+
connection: keep-alive
|
|
16
|
+
Content-Type: application/json
|
|
17
|
+
User-Agent: Augment.vscode-augment/0.654.1 (win32; x64; 10.0.26100) vscode/1.106.3
|
|
18
|
+
x-request-id: f9b882d5-8be9-4745-aa80-66d19cd17d75
|
|
19
|
+
x-request-session-id: 334da8ee-d3cd-4881-8ec8-a1fcd08f6eef
|
|
20
|
+
Authorization: Bearer d5351ac0bea26c7a5f4d956af9aa4cb3e5bf8da889447357df0e45ee725fc8bc
|
|
21
|
+
accept: */*
|
|
22
|
+
accept-language: *
|
|
23
|
+
sec-fetch-mode: cors
|
|
24
|
+
accept-encoding: br, gzip, deflate
|
|
25
|
+
sentry-trace: 7ff8be7e699ff3d88421c3242cf48d82-baca496bfa68b990
|
|
26
|
+
baggage: sentry-environment=production,sentry-release=vscode-extension%400.654.1,sentry-public_key=65b77c01171371d3328fc9a6d5941e00,sentry-trace_id=7ff8be7e699ff3d88421c3242cf48d82,sentry-org_id=4509262619082752
|
|
27
|
+
content-length: 2
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
settings {
|
|
31
|
+
encodeUrl: false
|
|
32
|
+
}
|