@dccxx/auggiegw 1.0.22 → 1.0.24

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 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-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
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
 
@@ -111,6 +112,28 @@ The `switch-account` command:
111
112
  - Switches to the account at index `currentIndex - 1` (the newer one)
112
113
  - After switching, calls `handleFetch({ authOnly: true, deleteSession: true })`
113
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
+
114
137
  ### Prompt File Format (lines 310-320)
115
138
 
116
139
  Prompts are saved as markdown with YAML frontmatter:
package/dist/cli.js CHANGED
@@ -2199,6 +2199,10 @@ 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");
2203
+ var CLAUDE_DIR = path.join(os.homedir(), ".claude");
2204
+ var CLAUDE_COMMANDS_DIR = path.join(CLAUDE_DIR, "commands");
2205
+ var CLAUDE_AGENTS_DIR = path.join(CLAUDE_DIR, "agents");
2202
2206
  function loadConfig() {
2203
2207
  const apiUrl = process.env.AUGMENT_GATEWAY_URL || "https://augmentgateway.1app.space";
2204
2208
  return { apiUrl };
@@ -2321,18 +2325,30 @@ async function getAllPrompts(token, apiUrl, spinner) {
2321
2325
  return allPrompts;
2322
2326
  }
2323
2327
  async function savePromptToFile(prompt) {
2324
- try {
2325
- await fs.mkdir(AUGMENT_COMMANDS_DIR, { recursive: true });
2326
- const markdownContent = `---
2328
+ const markdownContent = `---
2327
2329
  description: ${prompt.name}
2328
2330
  type: "manual"
2329
2331
  ---
2330
2332
 
2331
2333
  ${prompt.content}`;
2334
+ let augmentError = null;
2335
+ let claudeError = null;
2336
+ try {
2337
+ await fs.mkdir(AUGMENT_COMMANDS_DIR, { recursive: true });
2332
2338
  const filePath = path.join(AUGMENT_COMMANDS_DIR, `${prompt.command}.md`);
2333
2339
  await fs.writeFile(filePath, markdownContent, "utf-8");
2334
2340
  } catch (error) {
2335
- throw new Error(`Failed to save prompt file for command '${prompt.command}': ${error}`);
2341
+ augmentError = new Error(`Failed to save to .augment: ${error}`);
2342
+ }
2343
+ try {
2344
+ await fs.mkdir(CLAUDE_COMMANDS_DIR, { recursive: true });
2345
+ const filePath = path.join(CLAUDE_COMMANDS_DIR, `${prompt.command}.md`);
2346
+ await fs.writeFile(filePath, markdownContent, "utf-8");
2347
+ } catch (error) {
2348
+ claudeError = new Error(`Failed to save to .claude: ${error}`);
2349
+ }
2350
+ if (augmentError && claudeError) {
2351
+ throw new Error(`Failed to save prompt file for command '${prompt.command}': ${augmentError.message}; ${claudeError.message}`);
2336
2352
  }
2337
2353
  }
2338
2354
  async function deleteAllCommandFiles() {
@@ -2348,6 +2364,48 @@ async function deleteAllCommandFiles() {
2348
2364
  }
2349
2365
  return mdFiles.length;
2350
2366
  }
2367
+ async function getKit(kitId, apiUrl) {
2368
+ const response = await fetch(`${apiUrl}/api/public/kit/${kitId}`, {
2369
+ method: "GET"
2370
+ });
2371
+ if (!response.ok) {
2372
+ throw new Error(`HTTP error! status: ${response.status}`);
2373
+ }
2374
+ const data = await response.json();
2375
+ if (!data.success) {
2376
+ throw new Error(data.message || "Failed to get kit");
2377
+ }
2378
+ return data;
2379
+ }
2380
+ async function saveSubagentToFile(subagent) {
2381
+ const markdownContent = `---
2382
+ name: "${subagent.name}"
2383
+ description: "${subagent.description}"
2384
+ model: "${subagent.model}"
2385
+ color: "${subagent.color}"
2386
+ ---
2387
+
2388
+ ${subagent.content}`;
2389
+ let augmentError = null;
2390
+ let claudeError = null;
2391
+ try {
2392
+ await fs.mkdir(AUGMENT_AGENTS_DIR, { recursive: true });
2393
+ const filePath = path.join(AUGMENT_AGENTS_DIR, `${subagent.name}.md`);
2394
+ await fs.writeFile(filePath, markdownContent, "utf-8");
2395
+ } catch (error) {
2396
+ augmentError = new Error(`Failed to save to .augment: ${error}`);
2397
+ }
2398
+ try {
2399
+ await fs.mkdir(CLAUDE_AGENTS_DIR, { recursive: true });
2400
+ const filePath = path.join(CLAUDE_AGENTS_DIR, `${subagent.name}.md`);
2401
+ await fs.writeFile(filePath, markdownContent, "utf-8");
2402
+ } catch (error) {
2403
+ claudeError = new Error(`Failed to save to .claude: ${error}`);
2404
+ }
2405
+ if (augmentError && claudeError) {
2406
+ throw new Error(`Failed to save subagent file for '${subagent.name}': ${augmentError.message}; ${claudeError.message}`);
2407
+ }
2408
+ }
2351
2409
  async function promptInput(question, hidden = false) {
2352
2410
  const rl = readline.createInterface({
2353
2411
  input: process.stdin,
@@ -2682,6 +2740,42 @@ async function handleSwitchAccount() {
2682
2740
  process.exit(1);
2683
2741
  }
2684
2742
  }
2743
+ async function handleKit(kitId) {
2744
+ if (!kitId) {
2745
+ console.error("Error: Kit ID is required");
2746
+ console.error("Usage: auggiegw kit <kit-id>");
2747
+ process.exit(1);
2748
+ }
2749
+ const spinner = ora("Fetching kit...").start();
2750
+ try {
2751
+ const config = loadConfig();
2752
+ spinner.text = `Fetching kit ${kitId}...`;
2753
+ const kitResponse = await getKit(kitId, config.apiUrl);
2754
+ const kit = kitResponse.data;
2755
+ spinner.text = `Processing kit "${kit.name}"...`;
2756
+ let promptsCount = 0;
2757
+ let subagentsCount = 0;
2758
+ if (kit.prompts && kit.prompts.length > 0) {
2759
+ spinner.text = `Saving ${kit.prompts.length} prompts...`;
2760
+ for (const prompt of kit.prompts) {
2761
+ await savePromptToFile(prompt);
2762
+ promptsCount++;
2763
+ }
2764
+ }
2765
+ if (kit.subagents && kit.subagents.length > 0) {
2766
+ spinner.text = `Saving ${kit.subagents.length} subagents...`;
2767
+ for (const subagent of kit.subagents) {
2768
+ await saveSubagentToFile(subagent);
2769
+ subagentsCount++;
2770
+ }
2771
+ }
2772
+ spinner.succeed(`Successfully installed kit "${kit.name}": ${promptsCount} prompts, ${subagentsCount} subagents
2773
+ Files saved to ~/.augment/ and ~/.claude/ directories`);
2774
+ } catch (error) {
2775
+ spinner.fail(`Kit fetch failed: ${error}`);
2776
+ process.exit(1);
2777
+ }
2778
+ }
2685
2779
  var program2 = new Command;
2686
2780
  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");
2687
2781
  program2.command("login [username] [password]").description("Login and store credentials").action(handleLogin);
@@ -2702,6 +2796,7 @@ program2.command("exec <command> [args...]").description("Execute any custom com
2702
2796
  handleExec(command, args, sessionOptions);
2703
2797
  });
2704
2798
  program2.command("switch-account").description("Switch to a newer account from the purchased account list").action(handleSwitchAccount);
2799
+ program2.command("kit <kit-id>").description("Fetch and install a kit (prompts and subagents) from the public API").action(handleKit);
2705
2800
  program2.parse();
2706
2801
 
2707
- //# debugId=31D9A45346BDA22864756E2164756E21
2802
+ //# debugId=31C1CEB51905863664756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dccxx/auggiegw",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
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": {
@@ -0,0 +1,140 @@
1
+ # Kit Command - Requirements
2
+
3
+ ## Feature Overview
4
+
5
+ The `kit` command enables users to fetch and install pre-packaged collections of prompts and subagents from a public API endpoint. A "kit" is a bundle containing custom prompts and subagents that extend the functionality of the Auggie CLI. Files are synced to dual directories for compatibility: `~/.augment/commands/` and `~/.claude/commands/` for prompts, `~/.augment/agents/` and `~/.claude/agents/` for subagents.
6
+
7
+ ## User Story
8
+
9
+ **As a** CLI user
10
+ **I want to** install a kit by providing its ID
11
+ **So that** I can quickly add multiple prompts and subagents to my Auggie environment without manual configuration
12
+
13
+ ## Implementation Reference
14
+
15
+ - Entry point: `src/cli.ts:883-929` (handleKit function)
16
+ - API function: `src/cli.ts:369-385` (getKit function)
17
+ - Data models: `src/cli.ts:90-110` (SubagentData, KitData, GetKitResponse)
18
+ - File writers: `src/cli.ts:333-349` (savePromptToFile), `src/cli.ts:387-405` (saveSubagentToFile)
19
+
20
+ ## Acceptance Criteria
21
+
22
+ ### Command Invocation
23
+
24
+ - [x] WHEN the user runs `auggiegw kit <kit-id>`, THE SYSTEM SHALL fetch the kit from the public API endpoint.
25
+ - [x] IF the kit-id argument is missing, THEN THE SYSTEM SHALL display "Error: Kit ID is required" and usage message, and exit with code 1.
26
+
27
+ ### API Integration
28
+
29
+ - [x] THE SYSTEM SHALL make a GET request to `{apiUrl}/api/public/kit/{kitId}` without authentication headers.
30
+ - [x] THE SYSTEM SHALL parse the response as JSON with structure `{ success: boolean, message: string, data: KitData }`.
31
+ - [x] IF the HTTP response status is not OK, THEN THE SYSTEM SHALL throw an error with message "HTTP error! status: {status}".
32
+ - [x] IF the response `success` field is false, THEN THE SYSTEM SHALL throw an error with the API's message or "Failed to get kit".
33
+
34
+ ### Data Processing
35
+
36
+ - [x] WHEN the kit data is received, THE SYSTEM SHALL extract the kit name, prompts array, and subagents array.
37
+ - [x] THE SYSTEM SHALL process prompts sequentially before processing subagents.
38
+ - [x] THE SYSTEM SHALL track the count of successfully saved prompts and subagents.
39
+
40
+ ### Prompt Installation
41
+
42
+ - [x] WHEN processing prompts, THE SYSTEM SHALL create the directory `~/.augment/commands/` if it does not exist.
43
+ - [x] WHEN processing prompts, THE SYSTEM SHALL create the directory `~/.claude/commands/` if it does not exist.
44
+ - [x] FOR EACH prompt in the kit, THE SYSTEM SHALL save a markdown file to `~/.augment/commands/{command}.md` with YAML frontmatter containing `description` and `type: "manual"` fields.
45
+ - [x] FOR EACH prompt in the kit, THE SYSTEM SHALL save a markdown file to `~/.claude/commands/{command}.md` with YAML frontmatter containing `description` and `type: "manual"` fields.
46
+ - [x] THE SYSTEM SHALL overwrite existing prompt files with the same filename without confirmation.
47
+ - [x] IF a prompt file fails to save, THEN THE SYSTEM SHALL throw an error with message "Failed to save prompt file for command '{command}': {error}".
48
+ - [x] IF a prompt file fails to save to one directory (either `.augment` or `.claude`), THEN THE SYSTEM SHALL still attempt to save to the other directory before throwing an error.
49
+
50
+ ### Subagent Installation
51
+
52
+ - [x] WHEN processing subagents, THE SYSTEM SHALL create the directory `~/.augment/agents/` if it does not exist.
53
+ - [x] WHEN processing subagents, THE SYSTEM SHALL create the directory `~/.claude/agents/` if it does not exist.
54
+ - [x] FOR EACH subagent in the kit, THE SYSTEM SHALL save a markdown file to `~/.augment/agents/{name}.md` with YAML frontmatter containing `name`, `description`, `model`, and `color` fields.
55
+ - [x] FOR EACH subagent in the kit, THE SYSTEM SHALL save a markdown file to `~/.claude/agents/{name}.md` with YAML frontmatter containing `name`, `description`, `model`, and `color` fields.
56
+ - [x] THE SYSTEM SHALL overwrite existing subagent files with the same filename without confirmation.
57
+ - [x] IF a subagent file fails to save, THEN THE SYSTEM SHALL throw an error with message "Failed to save subagent file for '{name}': {error}".
58
+ - [x] IF a subagent file fails to save to one directory (either `.augment` or `.claude`), THEN THE SYSTEM SHALL still attempt to save to the other directory before throwing an error.
59
+
60
+ ### User Feedback
61
+
62
+ - [x] WHILE fetching the kit, THE SYSTEM SHALL display a spinner with text "Fetching kit {kitId}...".
63
+ - [x] WHILE processing the kit, THE SYSTEM SHALL update the spinner text to "Processing kit \"{name}\"...".
64
+ - [x] WHILE saving prompts, THE SYSTEM SHALL update the spinner text to "Saving {count} prompts...".
65
+ - [x] WHILE saving subagents, THE SYSTEM SHALL update the spinner text to "Saving {count} subagents...".
66
+ - [x] WHEN installation completes successfully, THE SYSTEM SHALL display "Successfully installed kit \"{name}\": {promptsCount} prompts, {subagentsCount} subagents".
67
+ - [x] WHEN installation completes successfully, THE SYSTEM SHALL display a message indicating files were saved to both `~/.augment/` and `~/.claude/` directories.
68
+ - [x] IF any error occurs during the process, THEN THE SYSTEM SHALL display "Kit fetch failed: {error}" and exit with code 1.
69
+
70
+ ### File Format Specifications
71
+
72
+ - [x] THE SYSTEM SHALL format prompt files with YAML frontmatter followed by content, using the template:
73
+ ```
74
+ ---
75
+ description: {prompt.name}
76
+ type: "manual"
77
+ ---
78
+
79
+ {prompt.content}
80
+ ```
81
+
82
+ - [x] THE SYSTEM SHALL format subagent files with YAML frontmatter followed by content, using the template:
83
+ ```
84
+ ---
85
+ name: "{subagent.name}"
86
+ description: "{subagent.description}"
87
+ model: "{subagent.model}"
88
+ color: "{subagent.color}"
89
+ ---
90
+
91
+ {subagent.content}
92
+ ```
93
+
94
+ - [x] THE SYSTEM SHALL use identical file formats for both `~/.augment/` and `~/.claude/` directories.
95
+
96
+ ## API Contract
97
+
98
+ ### Request
99
+ - **Method**: GET
100
+ - **Endpoint**: `{apiUrl}/api/public/kit/{kitId}`
101
+ - **Authentication**: None (public endpoint)
102
+ - **Parameters**: `kitId` (path parameter)
103
+
104
+ ### Response
105
+ ```typescript
106
+ {
107
+ success: boolean;
108
+ message: string;
109
+ data: {
110
+ id: string;
111
+ name: string;
112
+ description: string;
113
+ prompts: Array<{
114
+ name: string; // Display name for frontmatter
115
+ command: string; // Filename (without .md extension)
116
+ content: string; // Markdown content body
117
+ }>;
118
+ subagents: Array<{
119
+ name: string; // Filename (without .md extension)
120
+ description: string;
121
+ model: string;
122
+ color: string;
123
+ content: string; // Markdown content body
124
+ }>;
125
+ };
126
+ }
127
+ ```
128
+
129
+ ## Implementation Notes
130
+
131
+ **Status**: Completed
132
+ **Last Updated**: 2026-01-20
133
+ **Files**: `src/cli.ts:883-929` (handleKit), `src/cli.ts:333-349` (savePromptToFile), `src/cli.ts:387-405` (saveSubagentToFile)
134
+ **Deviations**: None
135
+
136
+ ### Implementation Details
137
+ - Prompts saved to both: `~/.augment/commands/` and `~/.claude/commands/`
138
+ - Subagents saved to both: `~/.augment/agents/` and `~/.claude/agents/`
139
+ - Error handling: Attempts both directories even if one fails
140
+ - Success message indicates dual-directory syncing