megabuff 0.9.2 → 0.10.2
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/README.md +446 -8
- package/dist/cost.d.ts +59 -0
- package/dist/cost.d.ts.map +1 -0
- package/dist/cost.js +159 -0
- package/dist/cost.js.map +1 -0
- package/dist/index.js +1355 -85
- package/dist/index.js.map +1 -1
- package/dist/models.js +1 -1
- package/dist/models.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
</h1>
|
|
4
4
|
<div align="center">
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
AI-powered prompt optimizer with multi-provider support (OpenAI, Anthropic, Gemini, DeepSeek, xAI & more)
|
|
6
|
+
**🤖 CLI for Better prompts, transparent costs, & zero vendor lock-in. Optimize AI prompts across OpenAI, Claude, Gemini, Grok, xAI, and DeepSeek with detailed per-token pricing. BYOK keeps it honest.
|
|
7
|
+
**
|
|
9
8
|
|
|
10
9
|
🔑 BYOK (Bring Your Own Key) • 🎨 16 Beautiful Themes • ⚡ Lightning Fast
|
|
11
10
|
|
|
@@ -39,12 +38,18 @@ megabuff optimize "Rewrite this prompt to be clearer"
|
|
|
39
38
|
|
|
40
39
|
## ✨ Features
|
|
41
40
|
|
|
42
|
-
- 🤖 **Multi-Provider Support** - OpenAI, Anthropic Claude, Google Gemini, & more
|
|
41
|
+
- 🤖 **Multi-Provider Support** - OpenAI, Anthropic Claude, Google Gemini, xAI, DeepSeek & more
|
|
43
42
|
- 🔑 **BYOK Model** - Bring your own API key, full control
|
|
44
43
|
- 🎨 **16 Beautiful Themes** - Customize your CLI experience
|
|
44
|
+
- 🎭 **7 Optimization Styles** - Concise, detailed, technical, creative, formal, casual, balanced
|
|
45
|
+
- 🔧 **Custom System Prompts** - Ultimate control over optimization behavior
|
|
46
|
+
- 🔄 **Iterative Refinement** - Progressive improvement with multiple optimization passes
|
|
47
|
+
- 🔍 **Comparison Mode** - Test multiple providers side-by-side to find the best result
|
|
48
|
+
- 📊 **Prompt Analysis** - Get detailed feedback on strengths, weaknesses, and improvement suggestions
|
|
49
|
+
- 💰 **Cost Tracking** - Estimate and monitor API costs before running operations
|
|
45
50
|
- ⚡ **Lightning Fast** - Optimize prompts in seconds
|
|
46
51
|
- 📋 **Auto-Clipboard** - Results copied automatically
|
|
47
|
-
-
|
|
52
|
+
- 🔀 **Flexible Input** - Inline, file, pipe, or interactive
|
|
48
53
|
- 💾 **Multiple Output Formats** - Stdout, file, or interactive view
|
|
49
54
|
- 🔒 **Secure Storage** - Keychain support for API keys
|
|
50
55
|
- 🎯 **Smart Model Selection** - Auto-detects provider from model name
|
|
@@ -59,6 +64,12 @@ megabuff optimize "Rewrite this prompt to be clearer"
|
|
|
59
64
|
- [📦 Installation](#-installation)
|
|
60
65
|
- [⚡ Quick Start](#-quick-start)
|
|
61
66
|
- [🔐 Setup](#-setup)
|
|
67
|
+
- [🤖 Getting Your OpenAI API Key (BYOK)](#-getting-your-openai-api-key-byok)
|
|
68
|
+
- [🧠 Getting Your Anthropic API Key (BYOK)](#-getting-your-anthropic-api-key-byok)
|
|
69
|
+
- [✨ Getting Your Google Gemini API Key (BYOK)](#-getting-your-google-gemini-api-key-byok)
|
|
70
|
+
- [🚀 Getting Your xAI API Key (BYOK)](#-getting-your-xai-api-key-byok)
|
|
71
|
+
- [🔮 Getting Your DeepSeek API Key (BYOK)](#-getting-your-deepseek-api-key-byok)
|
|
72
|
+
- [Configuring Your API Key](#configuring-your-api-key)
|
|
62
73
|
- [⚙️ Configuration Commands](#️-configuration-commands)
|
|
63
74
|
- [🎨 Theme Commands](#-theme-commands)
|
|
64
75
|
- [💡 Usage](#-usage)
|
|
@@ -164,6 +175,50 @@ Ready to try **Gemini**? Here's how:
|
|
|
164
175
|
- Free tier is available for testing
|
|
165
176
|
- For production usage, you may need to enable billing in Google Cloud Console
|
|
166
177
|
|
|
178
|
+
### 🚀 Getting Your xAI API Key (BYOK)
|
|
179
|
+
|
|
180
|
+
Want to use **Grok**? Here's how to get started:
|
|
181
|
+
|
|
182
|
+
1. **Create an xAI account**
|
|
183
|
+
- Visit [x.ai](https://x.ai/) or the [xAI Console](https://console.x.ai/)
|
|
184
|
+
- Sign up or log in with your account
|
|
185
|
+
|
|
186
|
+
2. **Access the API Console**
|
|
187
|
+
- Navigate to the API section in the xAI Console
|
|
188
|
+
- You may need to join the API waitlist or request access
|
|
189
|
+
|
|
190
|
+
3. **Generate your API key**
|
|
191
|
+
- Click **Create API Key** or **Generate Key**
|
|
192
|
+
- Give your key a descriptive name (e.g., "MegaBuff CLI")
|
|
193
|
+
- Copy the key immediately
|
|
194
|
+
|
|
195
|
+
4. **Save your key immediately**
|
|
196
|
+
- xAI keys typically start with `xai-`
|
|
197
|
+
- Store it securely - you won't be able to view it again
|
|
198
|
+
|
|
199
|
+
### 🔮 Getting Your DeepSeek API Key (BYOK)
|
|
200
|
+
|
|
201
|
+
Ready to use **DeepSeek**? Follow these steps:
|
|
202
|
+
|
|
203
|
+
1. **Create a DeepSeek account**
|
|
204
|
+
- Visit [DeepSeek Platform](https://platform.deepseek.com/)
|
|
205
|
+
- Sign up or log in to your account
|
|
206
|
+
|
|
207
|
+
2. **Set up billing**
|
|
208
|
+
- Navigate to the billing section
|
|
209
|
+
- Add payment method or credits as required
|
|
210
|
+
- DeepSeek offers competitive pricing for API usage
|
|
211
|
+
|
|
212
|
+
3. **Generate your API key**
|
|
213
|
+
- Go to **API Keys** section in the dashboard
|
|
214
|
+
- Click **Create new key** or **Generate API key**
|
|
215
|
+
- Name it something like "MegaBuff CLI"
|
|
216
|
+
|
|
217
|
+
4. **Save your key immediately**
|
|
218
|
+
- DeepSeek keys typically start with `sk-`
|
|
219
|
+
- Copy and store it securely
|
|
220
|
+
- You won't be able to view the full key again after creation
|
|
221
|
+
|
|
167
222
|
### Configuring Your API Key
|
|
168
223
|
|
|
169
224
|
Once you have your provider API key, configure it using one of these methods:
|
|
@@ -422,6 +477,336 @@ megabuff optimize "prompt" --interactive
|
|
|
422
477
|
megabuff optimize "prompt" -o result.txt --no-copy
|
|
423
478
|
```
|
|
424
479
|
|
|
480
|
+
### 🎨 Optimization Styles
|
|
481
|
+
|
|
482
|
+
**Tailor the optimization to your needs!** Choose from 7 different styles:
|
|
483
|
+
|
|
484
|
+
```bash
|
|
485
|
+
# Balanced (default) - Well-rounded optimization
|
|
486
|
+
megabuff optimize "your prompt"
|
|
487
|
+
|
|
488
|
+
# Concise - Minimize tokens, maximize clarity
|
|
489
|
+
megabuff optimize "your prompt" --style concise
|
|
490
|
+
|
|
491
|
+
# Detailed - Add comprehensive context and examples
|
|
492
|
+
megabuff optimize "your prompt" --style detailed
|
|
493
|
+
|
|
494
|
+
# Technical - Perfect for code generation tasks
|
|
495
|
+
megabuff optimize "your prompt" --style technical
|
|
496
|
+
|
|
497
|
+
# Creative - Encourage imaginative outputs
|
|
498
|
+
megabuff optimize "your prompt" --style creative
|
|
499
|
+
|
|
500
|
+
# Formal - Professional, business-appropriate
|
|
501
|
+
megabuff optimize "your prompt" --style formal
|
|
502
|
+
|
|
503
|
+
# Casual - Friendly, conversational tone
|
|
504
|
+
megabuff optimize "your prompt" --style casual
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
**Available Styles:**
|
|
508
|
+
- `balanced` - Default, well-rounded optimization
|
|
509
|
+
- `concise` - Brief and to-the-point
|
|
510
|
+
- `detailed` - Comprehensive with examples
|
|
511
|
+
- `technical` - Precise technical terminology
|
|
512
|
+
- `creative` - Imaginative and flexible
|
|
513
|
+
- `formal` - Professional and structured
|
|
514
|
+
- `casual` - Conversational and approachable
|
|
515
|
+
|
|
516
|
+
### 🔧 Custom System Prompts
|
|
517
|
+
|
|
518
|
+
**Ultimate control!** Provide your own system prompt:
|
|
519
|
+
|
|
520
|
+
```bash
|
|
521
|
+
# Use a custom optimization strategy
|
|
522
|
+
megabuff optimize "your prompt" --system-prompt "Focus on making this prompt more concise while maintaining all technical details"
|
|
523
|
+
|
|
524
|
+
# Combine with any provider
|
|
525
|
+
megabuff optimize --provider anthropic "complex task" --system-prompt "Optimize for Claude's chain-of-thought reasoning"
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
**Pro Tips:**
|
|
529
|
+
- Custom prompts override all style and provider-specific optimizations
|
|
530
|
+
- Great for domain-specific optimization (legal, medical, scientific)
|
|
531
|
+
- Use to enforce company-specific prompt standards
|
|
532
|
+
|
|
533
|
+
### 🔄 Iterative Refinement
|
|
534
|
+
|
|
535
|
+
**Progressive improvement!** Run multiple optimization passes:
|
|
536
|
+
|
|
537
|
+
```bash
|
|
538
|
+
# Single pass (default)
|
|
539
|
+
megabuff optimize "your prompt"
|
|
540
|
+
|
|
541
|
+
# 3 iterations for progressive refinement
|
|
542
|
+
megabuff optimize "your prompt" --iterations 3
|
|
543
|
+
|
|
544
|
+
# Maximum refinement (5 passes)
|
|
545
|
+
megabuff optimize "complex prompt" --iterations 5
|
|
546
|
+
|
|
547
|
+
# Show output from each iteration (verbose mode)
|
|
548
|
+
megabuff optimize "your prompt" --iterations 3 --verbose
|
|
549
|
+
|
|
550
|
+
# Combine with styles and providers
|
|
551
|
+
megabuff optimize --iterations 3 --style detailed --provider anthropic "technical documentation"
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
**How it works:**
|
|
555
|
+
- Each iteration takes the previous output and optimizes it further
|
|
556
|
+
- Great for complex prompts that need multiple rounds of refinement
|
|
557
|
+
- Iterations are limited to 1-5 to balance quality and cost
|
|
558
|
+
- Progress is shown for each iteration with individual timing
|
|
559
|
+
|
|
560
|
+
**Verbose mode (`--verbose` or `-v`):**
|
|
561
|
+
- Shows the output from each iteration in real-time
|
|
562
|
+
- Helps you see how the prompt evolves with each pass
|
|
563
|
+
- Useful for understanding the optimization process
|
|
564
|
+
- Only displays iteration outputs when using multiple iterations
|
|
565
|
+
|
|
566
|
+
**When to use multiple iterations:**
|
|
567
|
+
- Complex, multi-part prompts
|
|
568
|
+
- Technical documentation that needs precision
|
|
569
|
+
- Creative writing prompts that benefit from layered refinement
|
|
570
|
+
- When you want the absolute best optimization possible
|
|
571
|
+
|
|
572
|
+
**Analyze before optimizing (`--analyze-first` or `-a`):**
|
|
573
|
+
- Get detailed analysis BEFORE optimization runs
|
|
574
|
+
- See exactly what will be improved
|
|
575
|
+
- Understand the prompt's weaknesses upfront
|
|
576
|
+
- Then automatically proceed with optimization
|
|
577
|
+
|
|
578
|
+
```bash
|
|
579
|
+
# Analyze first, then optimize
|
|
580
|
+
megabuff optimize "your prompt" --analyze-first
|
|
581
|
+
megabuff optimize "your prompt" -a --style technical
|
|
582
|
+
|
|
583
|
+
# Combine with iterations
|
|
584
|
+
megabuff optimize "your prompt" --analyze-first --iterations 3
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
### 🔍 Comparison Mode
|
|
588
|
+
|
|
589
|
+
**Can't decide which provider to use?** Test them all at once!
|
|
590
|
+
|
|
591
|
+
```bash
|
|
592
|
+
# Compare optimizations from all configured providers
|
|
593
|
+
megabuff optimize "your prompt" --compare
|
|
594
|
+
|
|
595
|
+
# Compare specific providers only
|
|
596
|
+
megabuff optimize "your prompt" --compare --providers openai,anthropic
|
|
597
|
+
megabuff optimize "your prompt" --compare --providers openai,anthropic,google
|
|
598
|
+
|
|
599
|
+
# Combine with styles and iterations
|
|
600
|
+
megabuff optimize "complex prompt" --compare --style technical
|
|
601
|
+
megabuff optimize "your prompt" --compare --iterations 3
|
|
602
|
+
megabuff optimize "your prompt" --compare --providers openai,deepseek --style concise
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
**How it works:**
|
|
606
|
+
- Runs optimization across all providers with configured API keys (or specified providers)
|
|
607
|
+
- Executes all providers in parallel for speed
|
|
608
|
+
- Shows side-by-side results with timing and statistics
|
|
609
|
+
- Requires at least 2 providers with configured API keys
|
|
610
|
+
|
|
611
|
+
**Select specific providers:**
|
|
612
|
+
- Use `--providers` flag with comma-separated provider names
|
|
613
|
+
- Example: `--providers openai,anthropic,google`
|
|
614
|
+
- Only tests the providers you specify (if they have API keys configured)
|
|
615
|
+
- Great for targeted comparisons
|
|
616
|
+
|
|
617
|
+
**What you'll see:**
|
|
618
|
+
- Individual results from each provider
|
|
619
|
+
- Duration and length statistics for each
|
|
620
|
+
- Average metrics across all successful providers
|
|
621
|
+
- Any errors or failures clearly marked
|
|
622
|
+
|
|
623
|
+
**When to use comparison mode:**
|
|
624
|
+
- Evaluating which provider works best for your use case
|
|
625
|
+
- Testing different AI approaches to the same problem
|
|
626
|
+
- Quality assurance - seeing multiple perspectives
|
|
627
|
+
- Finding the optimal provider for specific prompt types
|
|
628
|
+
- A/B testing between specific providers
|
|
629
|
+
|
|
630
|
+
**Pro Tips:**
|
|
631
|
+
- Configure multiple providers first using `megabuff config set`
|
|
632
|
+
- Results are NOT copied to clipboard (choose your favorite manually)
|
|
633
|
+
- Combine with `--iterations` for comprehensive testing
|
|
634
|
+
- Use `--style` to ensure consistent optimization approach across providers
|
|
635
|
+
- Use `--providers` to focus on specific providers you want to compare
|
|
636
|
+
|
|
637
|
+
### 💰 Cost Tracking & Estimation
|
|
638
|
+
|
|
639
|
+
**Know before you spend!** Estimate and track API costs for your operations with detailed per-token and per-model pricing information.
|
|
640
|
+
|
|
641
|
+
```bash
|
|
642
|
+
# Show cost estimate before running optimization
|
|
643
|
+
megabuff optimize "your prompt" --show-cost
|
|
644
|
+
|
|
645
|
+
# Only estimate cost without running (perfect for budgeting)
|
|
646
|
+
megabuff optimize "your prompt" --estimate-only
|
|
647
|
+
|
|
648
|
+
# Estimate with multiple iterations
|
|
649
|
+
megabuff optimize "your prompt" --iterations 3 --estimate-only
|
|
650
|
+
|
|
651
|
+
# Show cost for analysis
|
|
652
|
+
megabuff analyze "your prompt" --show-cost
|
|
653
|
+
|
|
654
|
+
# Estimate only for analysis
|
|
655
|
+
megabuff analyze "your prompt" --estimate-only
|
|
656
|
+
|
|
657
|
+
# Compare costs across providers (combine with --compare)
|
|
658
|
+
megabuff optimize "your prompt" --compare --show-cost
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
**What you see with `--show-cost`:**
|
|
662
|
+
|
|
663
|
+
**1. Initial Cost Estimate (before operation runs):**
|
|
664
|
+
- Model being used for the operation
|
|
665
|
+
- **Detailed pricing breakdown:**
|
|
666
|
+
- Input price per 1M tokens and per individual token
|
|
667
|
+
- Output price per 1M tokens and per individual token
|
|
668
|
+
- Estimated input tokens
|
|
669
|
+
- Estimated output tokens
|
|
670
|
+
- Estimated total cost in USD
|
|
671
|
+
|
|
672
|
+
**2. Actual Cost Summary (after operation completes):**
|
|
673
|
+
- Model used
|
|
674
|
+
- **Detailed pricing breakdown** (same as estimate)
|
|
675
|
+
- Actual input tokens used
|
|
676
|
+
- Actual output tokens used
|
|
677
|
+
- Actual total cost in USD
|
|
678
|
+
- Estimate accuracy percentage
|
|
679
|
+
|
|
680
|
+
**3. Comparison Mode Pricing:**
|
|
681
|
+
- Individual pricing details for each provider's model
|
|
682
|
+
- Total tokens used across all providers
|
|
683
|
+
- Total cost across all providers
|
|
684
|
+
- Average cost per provider
|
|
685
|
+
- Per-iteration cost breakdown (when using `--iterations`)
|
|
686
|
+
|
|
687
|
+
**Example output:**
|
|
688
|
+
```
|
|
689
|
+
💰 Cost Estimate
|
|
690
|
+
────────────────────────────────────────────────────────────────────────────────
|
|
691
|
+
Model: claude-sonnet-4-5
|
|
692
|
+
Pricing:
|
|
693
|
+
Input: $3.00/1M tokens ($0.000003000/token)
|
|
694
|
+
Output: $15.00/1M tokens ($0.000015000/token)
|
|
695
|
+
|
|
696
|
+
Input tokens: 512
|
|
697
|
+
Output tokens (est): 614
|
|
698
|
+
Estimated cost: $0.0025
|
|
699
|
+
────────────────────────────────────────────────────────────────────────────────
|
|
700
|
+
|
|
701
|
+
... [operation runs] ...
|
|
702
|
+
|
|
703
|
+
💰 Actual Cost
|
|
704
|
+
────────────────────────────────────────────────────────────────────────────────
|
|
705
|
+
Model: claude-sonnet-4-5
|
|
706
|
+
Pricing:
|
|
707
|
+
Input: $3.00/1M tokens ($0.000003000/token)
|
|
708
|
+
Output: $15.00/1M tokens ($0.000015000/token)
|
|
709
|
+
|
|
710
|
+
Optimization tokens: 512 in + 621 out
|
|
711
|
+
Optimization cost: $0.0025
|
|
712
|
+
Total cost: $0.0025
|
|
713
|
+
Estimate accuracy: 98.9%
|
|
714
|
+
────────────────────────────────────────────────────────────────────────────────
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
**How it works:**
|
|
718
|
+
- Estimates token count based on your prompt text (~4 chars per token)
|
|
719
|
+
- Uses current pricing for each model/provider
|
|
720
|
+
- Accounts for system prompts and iterations
|
|
721
|
+
- Shows detailed cost breakdown BEFORE making any API calls
|
|
722
|
+
- Displays actual costs with pricing details AFTER operations complete
|
|
723
|
+
- Compares estimate vs actual for accuracy tracking
|
|
724
|
+
|
|
725
|
+
**Pricing information (updated January 2025):**
|
|
726
|
+
|
|
727
|
+
| Provider | Model | Input (per 1M) | Output (per 1M) |
|
|
728
|
+
|----------|-------|----------------|-----------------|
|
|
729
|
+
| **OpenAI** | gpt-5.2 | $2.50 | $10.00 |
|
|
730
|
+
| | gpt-4o | $2.50 | $10.00 |
|
|
731
|
+
| | gpt-4o-mini | $0.15 | $0.60 |
|
|
732
|
+
| | gpt-4-turbo | $10.00 | $30.00 |
|
|
733
|
+
| **Anthropic** | claude-opus-4-5 | $15.00 | $75.00 |
|
|
734
|
+
| | claude-sonnet-4-5 | $3.00 | $15.00 |
|
|
735
|
+
| | claude-sonnet-4-0 | $3.00 | $15.00 |
|
|
736
|
+
| | claude-3-haiku | $0.25 | $1.25 |
|
|
737
|
+
| **Google** | gemini-2.5-pro | $1.25 | $5.00 |
|
|
738
|
+
| | gemini-2.5-flash | $0.075 | $0.30 |
|
|
739
|
+
| | gemini-2.0-flash | $0.075 | $0.30 |
|
|
740
|
+
| **xAI** | grok-beta | $5.00 | $15.00 |
|
|
741
|
+
| | grok-vision-beta | $5.00 | $15.00 |
|
|
742
|
+
| **DeepSeek** | deepseek-chat | $0.14 | $0.28 |
|
|
743
|
+
| | deepseek-reasoner | $0.55 | $2.19 |
|
|
744
|
+
|
|
745
|
+
*Prices are in USD per 1 million tokens*
|
|
746
|
+
|
|
747
|
+
**Cost calculation formula:**
|
|
748
|
+
```
|
|
749
|
+
Cost = (input_tokens / 1,000,000 × input_price) + (output_tokens / 1,000,000 × output_price)
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
**Pro Tips:**
|
|
753
|
+
- Use `--estimate-only` to preview costs before committing
|
|
754
|
+
- Compare costs between providers to find the most economical option
|
|
755
|
+
- Most operations cost less than $0.01 with efficient models (gemini-flash, gpt-4o-mini, deepseek-chat)
|
|
756
|
+
- Use `--show-cost` to track cumulative spending in sessions
|
|
757
|
+
- Detailed pricing information helps you understand exactly where costs come from
|
|
758
|
+
- Per-token prices are shown with 9 decimal precision for accuracy
|
|
759
|
+
- In comparison mode, you'll see pricing details for each provider side-by-side
|
|
760
|
+
|
|
761
|
+
### 📊 Prompt Analysis
|
|
762
|
+
|
|
763
|
+
**Not sure what's wrong with your prompt?** Get detailed AI-powered feedback!
|
|
764
|
+
|
|
765
|
+
```bash
|
|
766
|
+
# Analyze a prompt and get comprehensive feedback
|
|
767
|
+
megabuff analyze "Write a function that does stuff"
|
|
768
|
+
|
|
769
|
+
# Analyze from a file
|
|
770
|
+
megabuff analyze --file my-prompt.txt
|
|
771
|
+
|
|
772
|
+
# Use a specific provider for analysis
|
|
773
|
+
megabuff analyze --provider anthropic "Explain quantum computing"
|
|
774
|
+
|
|
775
|
+
# Save analysis to a file
|
|
776
|
+
megabuff analyze "your prompt" --output analysis.txt
|
|
777
|
+
|
|
778
|
+
# Analyze without copying to clipboard
|
|
779
|
+
megabuff analyze "your prompt" --no-copy
|
|
780
|
+
```
|
|
781
|
+
|
|
782
|
+
**What you get:**
|
|
783
|
+
- **Overall Assessment** - Summary of the prompt's quality and purpose
|
|
784
|
+
- **Strengths** - 3-5 specific things the prompt does well
|
|
785
|
+
- **Weaknesses & Issues** - Problems, ambiguities, or areas for improvement
|
|
786
|
+
- **Specific Suggestions** - Actionable recommendations for enhancement
|
|
787
|
+
- **Key Improvements** - The most impactful changes to prioritize
|
|
788
|
+
- **Clarity Score** - Numeric rating (1-10) with justification
|
|
789
|
+
|
|
790
|
+
**How it works:**
|
|
791
|
+
- AI analyzes your prompt structure, clarity, and effectiveness
|
|
792
|
+
- Provides constructive, actionable feedback
|
|
793
|
+
- Identifies ambiguities and missing context
|
|
794
|
+
- Suggests concrete improvements
|
|
795
|
+
- Results are automatically copied to clipboard (unless `--no-copy` is used)
|
|
796
|
+
|
|
797
|
+
**When to use prompt analysis:**
|
|
798
|
+
- Before optimizing - understand what needs fixing first
|
|
799
|
+
- Learning prompt engineering - see what makes prompts effective
|
|
800
|
+
- Debugging poor AI responses - identify prompt issues
|
|
801
|
+
- Quality assurance - validate prompts meet standards
|
|
802
|
+
- Training others - explain good vs. bad prompt patterns
|
|
803
|
+
|
|
804
|
+
**Pro Tips:**
|
|
805
|
+
- Use analysis before optimization to understand what to focus on
|
|
806
|
+
- Different providers may highlight different aspects - try multiple!
|
|
807
|
+
- Save analyses to build a library of prompt engineering patterns
|
|
808
|
+
- Combine with `optimize` - analyze first, then optimize based on feedback
|
|
809
|
+
|
|
425
810
|
---
|
|
426
811
|
|
|
427
812
|
## 🎯 Examples
|
|
@@ -453,8 +838,53 @@ megabuff theme set cyberpunk # Set theme
|
|
|
453
838
|
megabuff theme preview dracula # Preview first
|
|
454
839
|
megabuff theme list # See all options
|
|
455
840
|
|
|
841
|
+
# 🎭 Use optimization styles
|
|
842
|
+
megabuff optimize --style technical "Create a REST API"
|
|
843
|
+
megabuff optimize --style concise "long rambling prompt here"
|
|
844
|
+
megabuff optimize --style creative "Write a story about AI"
|
|
845
|
+
|
|
846
|
+
# 🔬 Custom system prompts for specialized use
|
|
847
|
+
megabuff optimize "medical diagnosis criteria" --system-prompt "Optimize for medical professionals. Use precise medical terminology."
|
|
848
|
+
|
|
849
|
+
# 🔄 Iterative refinement for best results
|
|
850
|
+
megabuff optimize --iterations 3 "draft blog post intro"
|
|
851
|
+
megabuff optimize --iterations 5 --style detailed "complex technical spec"
|
|
852
|
+
megabuff optimize --iterations 3 --verbose "See how it evolves"
|
|
853
|
+
|
|
854
|
+
# 🔍 Analyze first, then optimize
|
|
855
|
+
megabuff optimize --analyze-first "Write a function that does stuff"
|
|
856
|
+
megabuff optimize -a --style technical "Create a REST API endpoint"
|
|
857
|
+
megabuff optimize --analyze-first --iterations 3 "Complex prompt that needs work"
|
|
858
|
+
|
|
859
|
+
# 🔍 Compare multiple providers side-by-side
|
|
860
|
+
megabuff optimize --compare "Create a REST API for user management"
|
|
861
|
+
megabuff optimize --compare --style technical "Explain quantum entanglement"
|
|
862
|
+
megabuff optimize --compare --iterations 3 "Write a product description"
|
|
863
|
+
megabuff optimize --compare --providers openai,anthropic "Which AI writes better code?"
|
|
864
|
+
megabuff optimize --compare --providers openai,anthropic,google --style concise "Short & sweet"
|
|
865
|
+
|
|
866
|
+
# 📊 Analyze prompts for detailed feedback
|
|
867
|
+
megabuff analyze "Write a function that does stuff"
|
|
868
|
+
megabuff analyze --provider anthropic "Explain how neural networks work"
|
|
869
|
+
megabuff analyze --file draft-prompt.txt --output analysis-report.txt
|
|
870
|
+
megabuff analyze "Create a chatbot for customer support" --provider openai
|
|
871
|
+
|
|
872
|
+
# 💰 Cost tracking and estimation
|
|
873
|
+
megabuff optimize "your prompt" --show-cost
|
|
874
|
+
megabuff optimize "your prompt" --estimate-only
|
|
875
|
+
megabuff optimize "your prompt" --iterations 5 --estimate-only
|
|
876
|
+
megabuff analyze "your prompt" --show-cost
|
|
877
|
+
megabuff optimize --compare --providers openai,anthropic --show-cost "Cost comparison"
|
|
878
|
+
|
|
456
879
|
# 🔧 Power user combos
|
|
457
880
|
megabuff optimize --file long-prompt.txt --provider anthropic -o result.txt --interactive
|
|
881
|
+
megabuff optimize --provider deepseek --model deepseek-reasoner --style detailed "Complex reasoning task"
|
|
882
|
+
megabuff optimize --iterations 3 --style technical --provider anthropic "API documentation"
|
|
883
|
+
megabuff optimize --compare --providers openai,deepseek --style concise --iterations 2 "Head-to-head test"
|
|
884
|
+
|
|
885
|
+
# 💡 Analysis + Optimization workflow
|
|
886
|
+
megabuff analyze "my prompt" --output analysis.txt # Understand issues first
|
|
887
|
+
megabuff optimize "my prompt" --style technical # Then optimize based on feedback
|
|
458
888
|
```
|
|
459
889
|
|
|
460
890
|
---
|
|
@@ -575,11 +1005,18 @@ cd megabuff-cli
|
|
|
575
1005
|
# Install dependencies
|
|
576
1006
|
npm install
|
|
577
1007
|
|
|
578
|
-
# Run in dev mode
|
|
579
|
-
npm run dev optimize "Your prompt"
|
|
1008
|
+
# Run in dev mode (note the -- separator before arguments)
|
|
1009
|
+
npm run dev -- optimize "Your prompt"
|
|
1010
|
+
|
|
1011
|
+
# With flags (always use -- to pass arguments to the script)
|
|
1012
|
+
npm run dev -- optimize "Your prompt" --compare --providers openai,anthropic
|
|
1013
|
+
npm run dev -- optimize "Your prompt" --style technical --iterations 3
|
|
1014
|
+
npm run dev -- optimize "Your prompt" --compare --providers google,openai --style concise --iterations 3
|
|
1015
|
+
npm run dev -- optimize "Your prompt" --compare --providers google,openai --style concise --iterations 2 --verbose
|
|
580
1016
|
|
|
581
|
-
# Or use tsx directly
|
|
1017
|
+
# Or use tsx directly (no -- needed)
|
|
582
1018
|
npx tsx src/index.ts optimize "Your prompt"
|
|
1019
|
+
npx tsx src/index.ts optimize "Your prompt" --compare --providers openai,anthropic
|
|
583
1020
|
```
|
|
584
1021
|
|
|
585
1022
|
### 📦 Build & Publish
|
|
@@ -646,6 +1083,7 @@ git commit -m "Release preparation"
|
|
|
646
1083
|
npm version minor
|
|
647
1084
|
|
|
648
1085
|
# 3. Publish!
|
|
1086
|
+
npm login
|
|
649
1087
|
npm publish
|
|
650
1088
|
|
|
651
1089
|
# 4. Push tags
|
package/dist/cost.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Provider } from "./config.js";
|
|
2
|
+
/**
|
|
3
|
+
* Pricing information for different models (per 1M tokens)
|
|
4
|
+
* Prices are in USD and updated as of January 2025
|
|
5
|
+
*/
|
|
6
|
+
interface ModelPricing {
|
|
7
|
+
input: number;
|
|
8
|
+
output: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Estimate token count from text (rough approximation)
|
|
12
|
+
* More accurate token counting would require the actual tokenizer for each model
|
|
13
|
+
*/
|
|
14
|
+
export declare function estimateTokens(text: string): number;
|
|
15
|
+
/**
|
|
16
|
+
* Get pricing for a specific model
|
|
17
|
+
*/
|
|
18
|
+
export declare function getModelPricing(model: string): ModelPricing | null;
|
|
19
|
+
/**
|
|
20
|
+
* Calculate cost for a given number of tokens
|
|
21
|
+
*/
|
|
22
|
+
export declare function calculateCost(inputTokens: number, outputTokens: number, model: string): number;
|
|
23
|
+
/**
|
|
24
|
+
* Estimate cost for a prompt optimization
|
|
25
|
+
*/
|
|
26
|
+
export declare function estimateOptimizationCost(promptText: string, model: string, iterations?: number, systemPromptLength?: number): {
|
|
27
|
+
inputTokens: number;
|
|
28
|
+
outputTokens: number;
|
|
29
|
+
estimatedCost: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Estimate cost for a prompt analysis
|
|
33
|
+
*/
|
|
34
|
+
export declare function estimateAnalysisCost(promptText: string, model: string, systemPromptLength?: number): {
|
|
35
|
+
inputTokens: number;
|
|
36
|
+
outputTokens: number;
|
|
37
|
+
estimatedCost: number;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Format cost as a human-readable string
|
|
41
|
+
*/
|
|
42
|
+
export declare function formatCost(cost: number): string;
|
|
43
|
+
export declare function getDefaultModelForProvider(provider: Provider): string;
|
|
44
|
+
/**
|
|
45
|
+
* Format tokens with comma separators
|
|
46
|
+
*/
|
|
47
|
+
export declare function formatTokens(tokens: number): string;
|
|
48
|
+
/**
|
|
49
|
+
* Get detailed pricing breakdown for a model
|
|
50
|
+
*/
|
|
51
|
+
export declare function getPricingBreakdown(model: string): {
|
|
52
|
+
model: string;
|
|
53
|
+
inputPricePer1M: number;
|
|
54
|
+
outputPricePer1M: number;
|
|
55
|
+
inputPricePerToken: string;
|
|
56
|
+
outputPricePerToken: string;
|
|
57
|
+
} | null;
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=cost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost.d.ts","sourceRoot":"","sources":["../src/cost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;GAGG;AACH,UAAU,YAAY;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAClB;AA0CD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAInD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAElE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAU9F;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACpC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAU,EACtB,kBAAkB,GAAE,MAAY,GACjC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CA2BtE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAChC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,kBAAkB,GAAE,MAAY,GACjC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAetE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAU/C;AAcD,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAErE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,EAAE,MAAM,CAAC;CAC/B,GAAG,IAAI,CAaP"}
|