@dccxx/auggiegw 1.0.21 → 1.0.23
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 +35 -13
- package/dist/cli.js +74 -32
- package/package.json +2 -1
package/CLAUDE.md
CHANGED
|
@@ -40,12 +40,12 @@ just release
|
|
|
40
40
|
|
|
41
41
|
Single-file CLI application (`src/cli.ts`) using Commander.js. All logic is contained in one file with clear separation:
|
|
42
42
|
|
|
43
|
-
1. **Type Definitions** (lines 18-
|
|
44
|
-
2. **Constants** (lines
|
|
45
|
-
3. **Utility Functions** (lines
|
|
46
|
-
4. **API Functions** (lines
|
|
47
|
-
5. **Command Handlers** (lines
|
|
48
|
-
6. **CLI Setup** (lines
|
|
43
|
+
1. **Type Definitions** (lines 18-162): All interfaces for API responses and internal data structures
|
|
44
|
+
2. **Constants** (lines 164-169): File paths for auth and session storage
|
|
45
|
+
3. **Utility Functions** (lines 171-254): Config loading, auth data management
|
|
46
|
+
4. **API Functions** (lines 265-518): HTTP calls to Augment Gateway API
|
|
47
|
+
5. **Command Handlers** (lines 520-929): Business logic for each CLI command
|
|
48
|
+
6. **CLI Setup** (lines 931-988): Commander.js program definition
|
|
49
49
|
|
|
50
50
|
### Key File Locations
|
|
51
51
|
|
|
@@ -53,6 +53,7 @@ Single-file CLI application (`src/cli.ts`) using Commander.js. All logic is cont
|
|
|
53
53
|
- Augment session: `~/.augment/session.json`
|
|
54
54
|
- Custom prompts: `~/.augment/commands/*.md`
|
|
55
55
|
- Auggie sessions: `~/.augment/sessions/*.json`
|
|
56
|
+
- Subagents: `~/.augment/agents/*.md`
|
|
56
57
|
|
|
57
58
|
## Special Logic & Non-Obvious Implementations
|
|
58
59
|
|
|
@@ -95,10 +96,13 @@ When `--refresh-commands` is provided:
|
|
|
95
96
|
3. Saves the fetched prompts to `~/.augment/commands/`
|
|
96
97
|
|
|
97
98
|
When `--refresh-commands` is NOT provided (default):
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
1. Fetches all prompts from the API using `getAllPrompts()`
|
|
100
|
+
2. Saves/overwrites prompts to `~/.augment/commands/` (existing files are overwritten)
|
|
101
|
+
3. Does NOT delete local commands that aren't on the server
|
|
100
102
|
|
|
101
|
-
The `--
|
|
103
|
+
The key difference: `--refresh-commands` does a full clean sync (deletes all local first), while the default only syncs server prompts to local without removing extra local files.
|
|
104
|
+
|
|
105
|
+
The `--auth-only` flag takes precedence and skips all prompt operations.
|
|
102
106
|
|
|
103
107
|
### Account Switching Logic (lines 714-770)
|
|
104
108
|
|
|
@@ -108,6 +112,28 @@ The `switch-account` command:
|
|
|
108
112
|
- Switches to the account at index `currentIndex - 1` (the newer one)
|
|
109
113
|
- After switching, calls `handleFetch({ authOnly: true, deleteSession: true })`
|
|
110
114
|
|
|
115
|
+
### Kit Command Logic (lines 883-929)
|
|
116
|
+
|
|
117
|
+
The `kit <kit-id>` command fetches and installs a kit from the public API:
|
|
118
|
+
1. Calls `/api/public/kit/{kit-id}` to fetch kit data (no authentication required)
|
|
119
|
+
2. Saves prompts to `~/.augment/commands/*.md` using the same format as `savePromptToFile`
|
|
120
|
+
3. Saves subagents to `~/.augment/agents/*.md` with YAML frontmatter
|
|
121
|
+
|
|
122
|
+
### Subagent File Format
|
|
123
|
+
|
|
124
|
+
Subagents are saved as markdown with YAML frontmatter:
|
|
125
|
+
|
|
126
|
+
```markdown
|
|
127
|
+
---
|
|
128
|
+
name: "{subagent.name}"
|
|
129
|
+
description: "{subagent.description}"
|
|
130
|
+
model: "{subagent.model}"
|
|
131
|
+
color: "{subagent.color}"
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
{subagent.content}
|
|
135
|
+
```
|
|
136
|
+
|
|
111
137
|
### Prompt File Format (lines 310-320)
|
|
112
138
|
|
|
113
139
|
Prompts are saved as markdown with YAML frontmatter:
|
|
@@ -121,10 +147,6 @@ type: "manual"
|
|
|
121
147
|
{prompt.content}
|
|
122
148
|
```
|
|
123
149
|
|
|
124
|
-
### Auto-Fix Commands on Fetch
|
|
125
|
-
|
|
126
|
-
When running `fetch` (without `--auth-only`), the CLI automatically fixes existing command files by adding `type: "manual"` if missing. This happens after authentication and before the success message.
|
|
127
|
-
|
|
128
150
|
### Authentication Token Resolution (lines 197-205)
|
|
129
151
|
|
|
130
152
|
`getAuthToken()` checks environment variable `AUGGIEGW_AUTH_TOKEN` first, then falls back to reading from `~/.auggiegw/auth.json`.
|
package/dist/cli.js
CHANGED
|
@@ -2199,6 +2199,7 @@ var AUTH_FILE = path.join(AUTH_DIR, "auth.json");
|
|
|
2199
2199
|
var AUGMENT_DIR = path.join(os.homedir(), ".augment");
|
|
2200
2200
|
var AUGMENT_SESSION_FILE = path.join(AUGMENT_DIR, "session.json");
|
|
2201
2201
|
var AUGMENT_COMMANDS_DIR = path.join(AUGMENT_DIR, "commands");
|
|
2202
|
+
var AUGMENT_AGENTS_DIR = path.join(AUGMENT_DIR, "agents");
|
|
2202
2203
|
function loadConfig() {
|
|
2203
2204
|
const apiUrl = process.env.AUGMENT_GATEWAY_URL || "https://augmentgateway.1app.space";
|
|
2204
2205
|
return { apiUrl };
|
|
@@ -2348,34 +2349,35 @@ async function deleteAllCommandFiles() {
|
|
|
2348
2349
|
}
|
|
2349
2350
|
return mdFiles.length;
|
|
2350
2351
|
}
|
|
2351
|
-
async function
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
}
|
|
2355
|
-
|
|
2352
|
+
async function getKit(kitId, apiUrl) {
|
|
2353
|
+
const response = await fetch(`${apiUrl}/api/public/kit/${kitId}`, {
|
|
2354
|
+
method: "GET"
|
|
2355
|
+
});
|
|
2356
|
+
if (!response.ok) {
|
|
2357
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
2356
2358
|
}
|
|
2357
|
-
const
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2359
|
+
const data = await response.json();
|
|
2360
|
+
if (!data.success) {
|
|
2361
|
+
throw new Error(data.message || "Failed to get kit");
|
|
2362
|
+
}
|
|
2363
|
+
return data;
|
|
2364
|
+
}
|
|
2365
|
+
async function saveSubagentToFile(subagent) {
|
|
2366
|
+
try {
|
|
2367
|
+
await fs.mkdir(AUGMENT_AGENTS_DIR, { recursive: true });
|
|
2368
|
+
const markdownContent = `---
|
|
2369
|
+
name: "${subagent.name}"
|
|
2370
|
+
description: "${subagent.description}"
|
|
2371
|
+
model: "${subagent.model}"
|
|
2372
|
+
color: "${subagent.color}"
|
|
2373
|
+
---
|
|
2374
|
+
|
|
2375
|
+
${subagent.content}`;
|
|
2376
|
+
const filePath = path.join(AUGMENT_AGENTS_DIR, `${subagent.name}.md`);
|
|
2377
|
+
await fs.writeFile(filePath, markdownContent, "utf-8");
|
|
2378
|
+
} catch (error) {
|
|
2379
|
+
throw new Error(`Failed to save subagent file for '${subagent.name}': ${error}`);
|
|
2377
2380
|
}
|
|
2378
|
-
return updatedCount;
|
|
2379
2381
|
}
|
|
2380
2382
|
async function promptInput(question, hidden = false) {
|
|
2381
2383
|
const rl = readline.createInterface({
|
|
@@ -2623,12 +2625,16 @@ async function handleFetch(options) {
|
|
|
2623
2625
|
spinner.warn(`Deleted ${deletedCount} commands, no new prompts found`);
|
|
2624
2626
|
}
|
|
2625
2627
|
} else {
|
|
2626
|
-
spinner.text = "
|
|
2627
|
-
const
|
|
2628
|
-
if (
|
|
2629
|
-
spinner.
|
|
2628
|
+
spinner.text = "Fetching prompts from server...";
|
|
2629
|
+
const allPrompts = await getAllPrompts(token, config.apiUrl, spinner);
|
|
2630
|
+
if (allPrompts.length > 0) {
|
|
2631
|
+
spinner.text = `Saving ${allPrompts.length} prompts...`;
|
|
2632
|
+
for (const prompt of allPrompts) {
|
|
2633
|
+
await savePromptToFile(prompt);
|
|
2634
|
+
}
|
|
2635
|
+
spinner.succeed(`Successfully synced ${allPrompts.length} prompts from server`);
|
|
2630
2636
|
} else {
|
|
2631
|
-
spinner.succeed("Authentication successful (
|
|
2637
|
+
spinner.succeed("Authentication successful (no prompts found on server)");
|
|
2632
2638
|
}
|
|
2633
2639
|
}
|
|
2634
2640
|
}
|
|
@@ -2707,6 +2713,41 @@ async function handleSwitchAccount() {
|
|
|
2707
2713
|
process.exit(1);
|
|
2708
2714
|
}
|
|
2709
2715
|
}
|
|
2716
|
+
async function handleKit(kitId) {
|
|
2717
|
+
if (!kitId) {
|
|
2718
|
+
console.error("Error: Kit ID is required");
|
|
2719
|
+
console.error("Usage: auggiegw kit <kit-id>");
|
|
2720
|
+
process.exit(1);
|
|
2721
|
+
}
|
|
2722
|
+
const spinner = ora("Fetching kit...").start();
|
|
2723
|
+
try {
|
|
2724
|
+
const config = loadConfig();
|
|
2725
|
+
spinner.text = `Fetching kit ${kitId}...`;
|
|
2726
|
+
const kitResponse = await getKit(kitId, config.apiUrl);
|
|
2727
|
+
const kit = kitResponse.data;
|
|
2728
|
+
spinner.text = `Processing kit "${kit.name}"...`;
|
|
2729
|
+
let promptsCount = 0;
|
|
2730
|
+
let subagentsCount = 0;
|
|
2731
|
+
if (kit.prompts && kit.prompts.length > 0) {
|
|
2732
|
+
spinner.text = `Saving ${kit.prompts.length} prompts...`;
|
|
2733
|
+
for (const prompt of kit.prompts) {
|
|
2734
|
+
await savePromptToFile(prompt);
|
|
2735
|
+
promptsCount++;
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
if (kit.subagents && kit.subagents.length > 0) {
|
|
2739
|
+
spinner.text = `Saving ${kit.subagents.length} subagents...`;
|
|
2740
|
+
for (const subagent of kit.subagents) {
|
|
2741
|
+
await saveSubagentToFile(subagent);
|
|
2742
|
+
subagentsCount++;
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
spinner.succeed(`Successfully installed kit "${kit.name}": ${promptsCount} prompts, ${subagentsCount} subagents`);
|
|
2746
|
+
} catch (error) {
|
|
2747
|
+
spinner.fail(`Kit fetch failed: ${error}`);
|
|
2748
|
+
process.exit(1);
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2710
2751
|
var program2 = new Command;
|
|
2711
2752
|
program2.name("auggiegw").description("CLI tool for auggiegw authentication").version("1.0.0").option("--preserve-session", "Preserve Auggie session (do not delete chat history)").option("--delete-session", "Delete Auggie session (clear chat history)").option("--auth-only", "Fetch authentication session only without fetching prompts").option("--refresh-commands", "Delete all existing commands and fetch fresh ones from API");
|
|
2712
2753
|
program2.command("login [username] [password]").description("Login and store credentials").action(handleLogin);
|
|
@@ -2727,6 +2768,7 @@ program2.command("exec <command> [args...]").description("Execute any custom com
|
|
|
2727
2768
|
handleExec(command, args, sessionOptions);
|
|
2728
2769
|
});
|
|
2729
2770
|
program2.command("switch-account").description("Switch to a newer account from the purchased account list").action(handleSwitchAccount);
|
|
2771
|
+
program2.command("kit <kit-id>").description("Fetch and install a kit (prompts and subagents) from the public API").action(handleKit);
|
|
2730
2772
|
program2.parse();
|
|
2731
2773
|
|
|
2732
|
-
//# debugId=
|
|
2774
|
+
//# debugId=C5CF051D7C5655BB64756E2164756E21
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dccxx/auggiegw",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"description": "A Node.js TypeScript package",
|
|
5
5
|
"main": "./dist/cli.js",
|
|
6
6
|
"types": "./dist/cli.d.ts",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"prepublishOnly": "bun run lint && bun run build",
|
|
16
16
|
"publish:auto": "node scripts/publish.js",
|
|
17
17
|
"dev:login": "bun run src/cli.ts login",
|
|
18
|
+
"dev:kit": "bun run src/cli.ts kit cmk4idkos0000ph7wwdy86a6f",
|
|
18
19
|
"dev:fetch": "bun run src/cli.ts fetch"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|