megabuff 0.1.0

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/PUBLISHING.md ADDED
@@ -0,0 +1,165 @@
1
+ # Publishing Checklist
2
+
3
+ Quick reference for publishing MegaBuff CLI to npm.
4
+
5
+ ## Pre-publish Checklist
6
+
7
+ - [ ] Update `package.json`:
8
+ - [ ] `author` field with your name/email
9
+ - [ ] `repository.url` with your GitHub URL
10
+ - [ ] `bugs.url` with your GitHub issues URL
11
+ - [ ] `homepage` with your GitHub README URL
12
+ - [ ] `version` is correct (use `npm version patch/minor/major`)
13
+
14
+ - [ ] Update `README.md`:
15
+ - [ ] Replace placeholder URLs
16
+ - [ ] Add screenshots/GIFs if available
17
+ - [ ] Test all code examples
18
+
19
+ - [ ] Code quality:
20
+ - [ ] Run `npm run build` successfully
21
+ - [ ] Test the CLI locally (`npm link`)
22
+ - [ ] All features working
23
+ - [ ] No TypeScript errors
24
+
25
+ - [ ] Git:
26
+ - [ ] All changes committed
27
+ - [ ] Pushed to GitHub
28
+ - [ ] Tagged with version (auto-created by `npm version`)
29
+
30
+ ## Publishing Commands
31
+
32
+ ## Testing Before Publishing
33
+
34
+ Always test the build before publishing to avoid publishing broken packages.
35
+
36
+ ### Quick Local Test
37
+
38
+ ```bash
39
+ # 1. Clean build
40
+ rm -rf dist/
41
+ npm run build
42
+
43
+ # 2. Link locally
44
+ npm link
45
+
46
+ # 3. Test commands
47
+ megabuff --version
48
+ megabuff config show
49
+ megabuff optimize "test prompt"
50
+
51
+ # 4. Clean up
52
+ npm unlink -g megabuff
53
+ ```
54
+
55
+ ### Recommended: Test Package Tarball
56
+
57
+ This simulates exactly what will be published:
58
+
59
+ ```bash
60
+ # 1. Create package tarball
61
+ npm pack
62
+
63
+ # 2. Inspect contents (optional)
64
+ tar -tzf megabuff-0.1.0.tgz
65
+
66
+ # 3. Install from tarball
67
+ npm install -g ./megabuff-0.1.0.tgz
68
+
69
+ # 4. Test thoroughly
70
+ megabuff --version
71
+ megabuff optimize "Write a function to validate email"
72
+ megabuff config set sk-test-key
73
+ megabuff config show
74
+
75
+ # 5. Clean up
76
+ npm uninstall -g megabuff
77
+ rm megabuff-0.1.0.tgz
78
+ ```
79
+
80
+ ### Dry Run (See What Would Be Published)
81
+
82
+ ```bash
83
+ # See what files will be included WITHOUT publishing
84
+ npm publish --dry-run
85
+
86
+ # Check for:
87
+ # ✅ dist/ folder included
88
+ # ❌ src/ folder excluded
89
+ # ❌ node_modules/ excluded
90
+ # ✅ README.md included
91
+ ```
92
+
93
+ ### What to Verify
94
+
95
+ - [ ] `dist/` folder exists with compiled JS
96
+ - [ ] Shebang preserved in `dist/index.js` (`#!/usr/bin/env node`)
97
+ - [ ] All commands work (`optimize`, `config`, etc.)
98
+ - [ ] Clipboard auto-copy works
99
+ - [ ] Config save/load works
100
+ - [ ] No TypeScript errors during build
101
+ - [ ] Package size is reasonable (check with `npm pack`)
102
+ - [ ] Only necessary files included (check with `tar -tzf`)
103
+
104
+ ## Publishing Commands
105
+
106
+ ### First Time
107
+
108
+ ```bash
109
+ # 1. Login to npm
110
+ npm login
111
+
112
+ # 2. Check if name is available
113
+ npm search megabuff
114
+
115
+ # 3. Test first (see above)
116
+ npm pack
117
+ npm install -g ./megabuff-0.1.0.tgz
118
+ # ... test thoroughly ...
119
+
120
+ # 4. Publish
121
+ npm publish
122
+ ```
123
+
124
+ ### Updates
125
+
126
+ ```bash
127
+ # 1. Update version (this also creates a git tag)
128
+ npm version patch # for bug fixes
129
+ npm version minor # for new features
130
+ npm version major # for breaking changes
131
+
132
+ # 2. Publish
133
+ npm publish
134
+
135
+ # 3. Push to GitHub
136
+ git push && git push --tags
137
+ ```
138
+
139
+ ## After Publishing
140
+
141
+ - [ ] Verify package on npm: https://www.npmjs.com/package/megabuff
142
+ - [ ] Test installation: `npm install -g megabuff`
143
+ - [ ] Test the installed CLI: `megabuff --version`
144
+ - [ ] Update GitHub release notes
145
+ - [ ] Tweet/share the release (optional)
146
+
147
+ ## Troubleshooting
148
+
149
+ **Error: Package name already exists**
150
+ - Change the `name` field in package.json to something unique
151
+
152
+ **Error: You must be logged in**
153
+ - Run `npm login` and enter your credentials
154
+
155
+ **Error: No permission to publish**
156
+ - Make sure you're logged in with the correct account
157
+ - If the package exists, you need to be a maintainer
158
+
159
+ **Build fails**
160
+ - Check TypeScript errors: `npm run build`
161
+ - Verify all dependencies are installed: `npm install`
162
+
163
+ **Package too large**
164
+ - Check `.npmignore` is excluding unnecessary files
165
+ - Run `npm pack` to see what's being included
package/README.md ADDED
@@ -0,0 +1,402 @@
1
+ # MegaBuff
2
+
3
+ AI prompt optimizer CLI - improve your prompts with multiple input/output options
4
+
5
+ ## Installation
6
+
7
+ Install MegaBuff globally:
8
+
9
+ ```bash
10
+ npm install -g megabuff
11
+ ```
12
+
13
+ Or for development:
14
+
15
+ ```bash
16
+ git clone https://github.com/thesupermegabuff/megabuff-cli.git
17
+ cd megabuff-cli
18
+ npm install
19
+
20
+ # Originally used nvm use 22
21
+ ```
22
+
23
+ ## Setup
24
+
25
+ ### Getting Your OpenAI API Key (BYOK)
26
+
27
+ MegaBuff uses a **BYOK (Bring Your Own Key)** model, meaning you use your own OpenAI API key. This gives you:
28
+ - ✅ Direct control over your usage and costs
29
+ - ✅ Pay-per-use pricing (typically pennies per optimization)
30
+ - ✅ Full privacy - your prompts go directly to OpenAI
31
+ - ✅ Ability to set your own usage limits
32
+
33
+ **Steps to get your OpenAI API Key:**
34
+
35
+ 1. **Create an OpenAI Account**
36
+ - Sign up or log in at [platform.openai.com](https://platform.openai.com/)
37
+ - Note: This is separate from the standard ChatGPT consumer site
38
+
39
+ 2. **Set up Billing**
40
+ - The API runs on a pay-per-use model
41
+ - Add a payment method in the [Billing](https://platform.openai.com/settings/organization/billing/overview) section
42
+ - You can set usage limits to manage costs
43
+ - Typical cost: ~$0.001-0.01 per prompt optimization (using gpt-4o-mini)
44
+
45
+ 3. **Generate Your API Key**
46
+ - Navigate to [API Keys](https://platform.openai.com/api-keys) in the sidebar
47
+ - Click **"+ Create new secret key"**
48
+ - Give your key a descriptive name (e.g., "MegaBuff CLI")
49
+ - Click **"Create secret key"**
50
+
51
+ 4. **Save Your Key Immediately**
52
+ - **Important**: Copy the key right away - OpenAI only shows it once!
53
+ - Store it securely - you'll need to generate a new one if you lose it
54
+ - The key starts with `sk-`
55
+
56
+ ### Configuring Your API Key
57
+
58
+ Once you have your OpenAI API key, configure it using one of these methods:
59
+
60
+ #### Option 1: Save to Config (Recommended)
61
+
62
+ The easiest way to get started:
63
+
64
+ ```bash
65
+ # Save to config file
66
+ megabuff config set sk-your-api-key-here
67
+
68
+ # Or save to system keychain (more secure)
69
+ megabuff config set sk-your-api-key-here --keychain
70
+ ```
71
+
72
+ This saves your key for future use. You only need to do this once!
73
+
74
+ #### Option 2: Environment Variable
75
+
76
+ ```bash
77
+ export OPENAI_API_KEY="sk-your-api-key-here"
78
+ ```
79
+
80
+ Add to your shell profile (`.bashrc`, `.zshrc`, etc.) to persist across sessions.
81
+
82
+ #### Option 3: Pass as Flag
83
+
84
+ ```bash
85
+ megabuff optimize "your prompt" --api-key sk-your-key-here
86
+ ```
87
+
88
+ ### API Key Priority
89
+
90
+ The CLI checks for your API key in this order:
91
+ 1. `--api-key` flag (highest priority)
92
+ 2. `OPENAI_API_KEY` environment variable
93
+ 3. System keychain (if configured)
94
+ 4. Config file at `~/.megabuff/config.json`
95
+
96
+ ## Configuration Commands
97
+
98
+ ```bash
99
+ # Save your API key
100
+ megabuff config set sk-your-api-key-here
101
+
102
+ # Save to keychain (macOS Keychain, Windows Credential Manager, Linux Secret Service)
103
+ megabuff config set sk-your-api-key-here --keychain
104
+
105
+ # Show current configuration
106
+ megabuff config show
107
+
108
+ # Remove saved API key
109
+ megabuff config remove
110
+ ```
111
+
112
+ ## Development
113
+
114
+ Test your CLI during development:
115
+
116
+ ```bash
117
+ # Using the dev script (recommended)
118
+ npm run dev optimize "Write a function to sort arrays"
119
+
120
+ # Or using npx tsx directly
121
+ npx tsx src/index.ts optimize "Your prompt here"
122
+
123
+ # Or install locally as a global command
124
+ npm link
125
+ megabuff optimize "Your prompt here"
126
+ ```
127
+
128
+ ## Build
129
+
130
+ Compile TypeScript to JavaScript:
131
+
132
+ ```bash
133
+ npm run build
134
+ ```
135
+
136
+ This will create compiled files in the `dist/` folder.
137
+
138
+ ## Install Globally
139
+
140
+ Install the CLI globally on your machine for testing:
141
+
142
+ ```bash
143
+ npm link
144
+ ```
145
+
146
+ ## Usage
147
+
148
+ The CLI supports multiple input methods:
149
+
150
+ ### 1. Inline Argument (Quick & Simple)
151
+
152
+ ```bash
153
+ megabuff optimize "Write a function that validates email addresses"
154
+ ```
155
+
156
+ ### 2. File Input
157
+
158
+ ```bash
159
+ megabuff optimize --file prompt.txt
160
+ ```
161
+
162
+ ### 3. Stdin Pipe
163
+
164
+ ```bash
165
+ echo "Explain quantum computing" | megabuff optimize
166
+ cat prompt.txt | megabuff optimize
167
+ ```
168
+
169
+ ### 4. Interactive Mode
170
+
171
+ ```bash
172
+ megabuff optimize
173
+ # Then paste/type your prompt and press Ctrl+D when done
174
+ ```
175
+
176
+ ## Output Options
177
+
178
+ ### Default: Print to stdout AND copy to clipboard
179
+
180
+ By default, the optimized prompt is:
181
+ 1. Printed to stdout (so you can pipe it)
182
+ 2. Automatically copied to your clipboard (works on macOS, Windows, and Linux)
183
+
184
+ ```bash
185
+ megabuff optimize "your prompt"
186
+ # Result is both printed AND copied to clipboard
187
+ ```
188
+
189
+ ### Disable clipboard copy
190
+
191
+ If you don't want automatic clipboard copy:
192
+
193
+ ```bash
194
+ megabuff optimize "your prompt" --no-copy
195
+ ```
196
+
197
+ ### Save to file
198
+
199
+ ```bash
200
+ megabuff optimize "your prompt" --output result.txt
201
+ # Still copies to clipboard by default
202
+ ```
203
+
204
+ ### Interactive comparison view
205
+
206
+ ```bash
207
+ megabuff optimize "your prompt" --interactive
208
+ # Shows before/after comparison AND copies to clipboard
209
+ ```
210
+
211
+ ### Combine options
212
+
213
+ ```bash
214
+ # Save to file without clipboard
215
+ megabuff optimize "your prompt" --output result.txt --no-copy
216
+
217
+ # Interactive view without clipboard
218
+ megabuff optimize "your prompt" --interactive --no-copy
219
+
220
+ # Pipe to another command (clipboard still works)
221
+ megabuff optimize "your prompt" | grep "specific"
222
+ ```
223
+
224
+ ## Examples
225
+
226
+ ```bash
227
+ # Quick inline optimization (auto-copies to clipboard)
228
+ megabuff optimize "Write code for user auth"
229
+
230
+ # From file with interactive view (auto-copies)
231
+ megabuff optimize --file my-prompt.txt --interactive
232
+
233
+ # Pipe and save (auto-copies)
234
+ cat input.txt | megabuff optimize --output optimized.txt
235
+
236
+ # Disable clipboard copy
237
+ megabuff optimize "Your prompt" --no-copy
238
+
239
+ # Save to file without clipboard
240
+ megabuff optimize --file prompt.txt --output result.txt --no-copy
241
+
242
+ # Use specific API key
243
+ megabuff optimize "Your prompt" --api-key sk-your-key-here
244
+ ```
245
+
246
+ ## How It Works
247
+
248
+ The CLI uses OpenAI's GPT-4o-mini model to analyze and optimize your prompts. It:
249
+
250
+ 1. Identifies ambiguities or unclear instructions
251
+ 2. Adds relevant context that would improve results
252
+ 3. Structures the prompt for clarity
253
+ 4. Specifies expected output format if not present
254
+ 5. Makes the prompt more specific and actionable
255
+
256
+ ## VS Code Integration
257
+
258
+ MegaBuff integrates seamlessly with VS Code in multiple ways:
259
+
260
+ ### Option 1: VS Code Extension (Full Experience)
261
+
262
+ Install and develop the MegaBuff VS Code extension:
263
+
264
+ ```bash
265
+ cd ../megabuff-vscode
266
+ npm install
267
+ npm run compile
268
+ ```
269
+
270
+ Then press `F5` to launch the extension in debug mode.
271
+
272
+ **Features:**
273
+ - Right-click context menu for selected text
274
+ - Command palette integration
275
+ - Keyboard shortcuts (`Ctrl+Shift+Alt+O`)
276
+ - Diff view for before/after comparison
277
+ - API key management UI
278
+ - Status bar integration
279
+
280
+ See [megabuff-vscode/README.md](../megabuff-vscode/README.md) for more details.
281
+
282
+ ### Option 2: VS Code Tasks (Quick Setup)
283
+
284
+ Use the pre-configured tasks in `.vscode/tasks.json`:
285
+
286
+ 1. Select text in VS Code
287
+ 2. Press `Ctrl+Shift+P` → "Tasks: Run Task"
288
+ 3. Choose "MegaBuff: Optimize Selected Text"
289
+
290
+ Available tasks:
291
+ - `MegaBuff: Optimize Selected Text`
292
+ - `MegaBuff: Optimize Current File`
293
+ - `MegaBuff: Optimize Selected (Interactive)`
294
+ - `MegaBuff: Configure API Key`
295
+
296
+ ### Option 3: Terminal Integration
297
+
298
+ Simply use the CLI in VS Code's integrated terminal:
299
+
300
+ ```bash
301
+ # Select text, then in terminal:
302
+ pbpaste | megabuff optimize # macOS
303
+ xclip -o | megabuff optimize # Linux
304
+ ```
305
+
306
+ ## Publishing to npm
307
+
308
+ ### First-time Setup
309
+
310
+ 1. **Create an npm account** at [npmjs.com/signup](https://www.npmjs.com/signup) if you don't have one
311
+
312
+ 2. **Login to npm** from your terminal:
313
+ ```bash
314
+ npm login
315
+ ```
316
+
317
+ 3. **Update package.json** with your information:
318
+ - Change `author` to your name and email
319
+ - Update `repository` URL with your GitHub username
320
+ - Update `bugs` and `homepage` URLs
321
+
322
+ 4. **Check if the package name is available**:
323
+ ```bash
324
+ npm search megabuff
325
+ ```
326
+ The name `megabuff` should be available (or use an alternative if taken)
327
+
328
+ ### Publishing Steps
329
+
330
+ 1. **Make sure everything is committed**:
331
+ ```bash
332
+ git status
333
+ git add .
334
+ git commit -m "Prepare for publish"
335
+ ```
336
+
337
+ 2. **Build the project**:
338
+ ```bash
339
+ npm run build
340
+ ```
341
+ This compiles TypeScript to JavaScript in the `dist/` folder
342
+
343
+ 3. **Test the package locally** (optional but recommended):
344
+ ```bash
345
+ npm pack
346
+ # This creates a .tgz file you can inspect
347
+ ```
348
+
349
+ 4. **Publish to npm**:
350
+ ```bash
351
+ npm publish
352
+ ```
353
+
354
+ The `prepublishOnly` script will automatically run `npm run build` before publishing.
355
+
356
+ ### Publishing Updates
357
+
358
+ When you make changes and want to publish a new version:
359
+
360
+ 1. **Update the version** using semantic versioning:
361
+ ```bash
362
+ # For bug fixes (0.1.0 -> 0.1.1)
363
+ npm version patch
364
+
365
+ # For new features (0.1.0 -> 0.2.0)
366
+ npm version minor
367
+
368
+ # For breaking changes (0.1.0 -> 1.0.0)
369
+ npm version major
370
+ ```
371
+
372
+ 2. **Publish the update**:
373
+ ```bash
374
+ npm publish
375
+ ```
376
+
377
+ 3. **Push the version tag to GitHub**:
378
+ ```bash
379
+ git push && git push --tags
380
+ ```
381
+
382
+ ### What Gets Published
383
+
384
+ The npm package includes:
385
+ - ✅ `dist/` - Compiled JavaScript
386
+ - ✅ `README.md` - Documentation
387
+ - ✅ `package.json` - Package metadata
388
+ - ✅ `LICENSE` - License file
389
+ - ❌ `src/` - TypeScript source (excluded)
390
+ - ❌ `node_modules/` - Dependencies (excluded)
391
+ - ❌ Development files (excluded via .npmignore)
392
+
393
+ ### After Publishing
394
+
395
+ Users can install your CLI globally with:
396
+ ```bash
397
+ npm install -g megabuff
398
+ ```
399
+
400
+ Your package will be available at:
401
+ - npm: `https://www.npmjs.com/package/megabuff`
402
+ - Docs: `https://github.com/thesupermegabuff/megabuff-cli`
@@ -0,0 +1,35 @@
1
+ interface Config {
2
+ apiKey?: string;
3
+ useKeychain?: boolean;
4
+ model?: string;
5
+ }
6
+ /**
7
+ * Get API key with priority:
8
+ * 1. Command line flag
9
+ * 2. Environment variable
10
+ * 3. Keychain (if configured)
11
+ * 4. Config file
12
+ */
13
+ export declare function getApiKey(cliKey?: string): Promise<string | undefined>;
14
+ /**
15
+ * Set API key in config or keychain
16
+ */
17
+ export declare function setApiKey(apiKey: string, useKeychain?: boolean): Promise<void>;
18
+ /**
19
+ * Get current configuration
20
+ */
21
+ export declare function getConfig(): Promise<Config>;
22
+ /**
23
+ * Update configuration
24
+ */
25
+ export declare function updateConfig(updates: Partial<Config>): Promise<void>;
26
+ /**
27
+ * Remove API key from config and keychain
28
+ */
29
+ export declare function removeApiKey(): Promise<void>;
30
+ /**
31
+ * Check if API key is configured
32
+ */
33
+ export declare function hasApiKey(): Promise<boolean>;
34
+ export {};
35
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AASA,UAAU,MAAM;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAkED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAuB5E;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB3F;AAED;;GAEG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAEjD;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAI1E;AAED;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAMlD;AAED;;GAEG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CASlD"}