mcp-prompt-optimizer 1.4.2 โ 2.2.3
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/CHANGELOG.md +78 -53
- package/CROSS-PLATFORM.md +3 -3
- package/README.md +99 -39
- package/index.js +843 -187
- package/lib/api-key-manager.js +191 -138
- package/lib/check-status.js +1 -1
- package/package.json +80 -5
- package/tests/README.md +0 -232
- package/tests/comprehensive-test.js +0 -692
- package/tests/integration-test.js +0 -446
- package/tests/minimal-test.js +0 -265
- package/tests/quick-test.js +0 -256
- package/tests/simple-test.js +0 -171
- package/tests/test-runner.js +0 -322
package/tests/README.md
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
# ๐งช MCP Prompt Optimizer Test Suite
|
|
2
|
-
|
|
3
|
-
Comprehensive testing framework for validating package functionality before NPM publication.
|
|
4
|
-
|
|
5
|
-
## ๐ Test Overview
|
|
6
|
-
|
|
7
|
-
### ๐ Quick Test (`npm run test:quick`)
|
|
8
|
-
**Duration:** ~30 seconds
|
|
9
|
-
**Purpose:** Rapid validation of core functionality
|
|
10
|
-
**API Key:** Not required (uses mock mode)
|
|
11
|
-
|
|
12
|
-
Tests:
|
|
13
|
-
- โ
Package structure validation
|
|
14
|
-
- โ
Cross-platform compatibility
|
|
15
|
-
- โ
MCP server instantiation
|
|
16
|
-
- โ
API key format validation
|
|
17
|
-
- โ
AI context detection
|
|
18
|
-
- โ
Mock optimization generation
|
|
19
|
-
- โ
Response formatting
|
|
20
|
-
- โ
Environment variable support
|
|
21
|
-
|
|
22
|
-
**Use Case:** Quick verification during development
|
|
23
|
-
|
|
24
|
-
### ๐ Integration Test (`npm run test:integration`)
|
|
25
|
-
**Duration:** ~60 seconds
|
|
26
|
-
**Purpose:** Validate API connectivity and real backend integration
|
|
27
|
-
**API Key:** Optional (falls back to mock mode)
|
|
28
|
-
|
|
29
|
-
Tests:
|
|
30
|
-
- โ
Backend connectivity
|
|
31
|
-
- โ
Real API key validation
|
|
32
|
-
- โ
Live optimization requests
|
|
33
|
-
- โ
Quota status retrieval
|
|
34
|
-
- โ
Template search functionality
|
|
35
|
-
- โ
Error recovery mechanisms
|
|
36
|
-
- โ
Network resilience
|
|
37
|
-
|
|
38
|
-
**Use Case:** Pre-deployment validation with real backend
|
|
39
|
-
|
|
40
|
-
### ๐ฌ Comprehensive Test (`npm run test:comprehensive`)
|
|
41
|
-
**Duration:** ~2 minutes
|
|
42
|
-
**Purpose:** Exhaustive validation of all features and edge cases
|
|
43
|
-
**API Key:** Optional (extensive mock testing)
|
|
44
|
-
|
|
45
|
-
Tests:
|
|
46
|
-
- โ
All quick test features
|
|
47
|
-
- โ
All integration test features
|
|
48
|
-
- โ
Command-line interface testing
|
|
49
|
-
- โ
Network resilience scenarios
|
|
50
|
-
- โ
Error handling edge cases
|
|
51
|
-
- โ
Package integrity validation
|
|
52
|
-
- โ
MCP protocol compliance
|
|
53
|
-
- โ
Cross-platform script testing
|
|
54
|
-
|
|
55
|
-
**Use Case:** Full validation before major releases
|
|
56
|
-
|
|
57
|
-
### ๐ฏ Test Runner (`npm test` or `npm run test:runner`)
|
|
58
|
-
**Duration:** ~3-4 minutes
|
|
59
|
-
**Purpose:** Orchestrates all test suites in optimal order
|
|
60
|
-
**API Key:** Optional (runs all modes)
|
|
61
|
-
|
|
62
|
-
**Use Case:** Complete pre-publication validation
|
|
63
|
-
|
|
64
|
-
## ๐ ๏ธ Usage Examples
|
|
65
|
-
|
|
66
|
-
### Basic Testing (No API Key Required)
|
|
67
|
-
```bash
|
|
68
|
-
# Quick validation
|
|
69
|
-
npm run test:quick
|
|
70
|
-
|
|
71
|
-
# Full test suite in mock mode
|
|
72
|
-
npm test
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Testing with Real API Key
|
|
76
|
-
```bash
|
|
77
|
-
# Set your API key
|
|
78
|
-
export OPTIMIZER_API_KEY=sk-opt-your-actual-key
|
|
79
|
-
|
|
80
|
-
# Run integration tests
|
|
81
|
-
npm run test:integration
|
|
82
|
-
|
|
83
|
-
# Run full test suite
|
|
84
|
-
npm test
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Development Mode Testing
|
|
88
|
-
```bash
|
|
89
|
-
# Enable development mode
|
|
90
|
-
export OPTIMIZER_DEV_MODE=true
|
|
91
|
-
export OPTIMIZER_API_KEY=sk-dev-test-key
|
|
92
|
-
|
|
93
|
-
# Run tests
|
|
94
|
-
npm test
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### Custom Backend Testing
|
|
98
|
-
```bash
|
|
99
|
-
# Test against custom backend
|
|
100
|
-
export OPTIMIZER_BACKEND_URL=https://your-backend.com
|
|
101
|
-
export OPTIMIZER_API_KEY=your-key
|
|
102
|
-
|
|
103
|
-
# Run integration tests
|
|
104
|
-
npm run test:integration
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## ๐ Test Output Examples
|
|
108
|
-
|
|
109
|
-
### โ
Success Output
|
|
110
|
-
```
|
|
111
|
-
๐ ALL TESTS PASSED - READY FOR PUBLICATION!
|
|
112
|
-
|
|
113
|
-
๐ Recommended publication commands:
|
|
114
|
-
npm publish
|
|
115
|
-
git tag v1.4.0
|
|
116
|
-
git push --tags
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### โ Failure Output
|
|
120
|
-
```
|
|
121
|
-
โ SOME TESTS FAILED - FIX ISSUES BEFORE PUBLICATION
|
|
122
|
-
Run the comprehensive test suite for detailed analysis:
|
|
123
|
-
node tests/comprehensive-test.js
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
## ๐ง Test Modes
|
|
127
|
-
|
|
128
|
-
### Mock Mode (Default)
|
|
129
|
-
- **Trigger:** No API key provided
|
|
130
|
-
- **Behavior:** Uses simulated responses
|
|
131
|
-
- **Tests:** All functionality except live API calls
|
|
132
|
-
- **Advantage:** Fast, no dependencies
|
|
133
|
-
|
|
134
|
-
### Development Mode
|
|
135
|
-
- **Trigger:** `OPTIMIZER_DEV_MODE=true`
|
|
136
|
-
- **Behavior:** Enhanced logging, extended timeouts
|
|
137
|
-
- **Tests:** All functionality with debug output
|
|
138
|
-
- **Advantage:** Detailed debugging information
|
|
139
|
-
|
|
140
|
-
### Production Mode
|
|
141
|
-
- **Trigger:** Real API key provided
|
|
142
|
-
- **Behavior:** Tests against live backend
|
|
143
|
-
- **Tests:** Full end-to-end validation
|
|
144
|
-
- **Advantage:** Real-world validation
|
|
145
|
-
|
|
146
|
-
## ๐ฏ Pre-Publication Checklist
|
|
147
|
-
|
|
148
|
-
Run this checklist before publishing to NPM:
|
|
149
|
-
|
|
150
|
-
1. **Quick Test** โ
|
|
151
|
-
```bash
|
|
152
|
-
npm run test:quick
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
2. **Integration Test** (if you have API key) โ
|
|
156
|
-
```bash
|
|
157
|
-
OPTIMIZER_API_KEY=your-key npm run test:integration
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
3. **Full Test Suite** โ
|
|
161
|
-
```bash
|
|
162
|
-
npm test
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
4. **Manual Verification** โ
|
|
166
|
-
- [ ] Version number updated in package.json
|
|
167
|
-
- [ ] CHANGELOG.md updated
|
|
168
|
-
- [ ] README.md current
|
|
169
|
-
- [ ] All files included in `files` array
|
|
170
|
-
|
|
171
|
-
5. **Publication** ๐
|
|
172
|
-
```bash
|
|
173
|
-
npm publish
|
|
174
|
-
git tag v$(node -p "require('./package.json').version")
|
|
175
|
-
git push --tags
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
## ๐จ Troubleshooting
|
|
179
|
-
|
|
180
|
-
### Common Issues
|
|
181
|
-
|
|
182
|
-
**"Tests failed with exit code 1"**
|
|
183
|
-
- Run individual test suites to identify specific failures
|
|
184
|
-
- Check error messages for detailed debugging information
|
|
185
|
-
|
|
186
|
-
**"Network error during integration tests"**
|
|
187
|
-
- Verify internet connection
|
|
188
|
-
- Check if backend URL is accessible
|
|
189
|
-
- Try running in mock mode first
|
|
190
|
-
|
|
191
|
-
**"API key validation failed"**
|
|
192
|
-
- Verify API key format: `sk-opt-`, `sk-team-`, `sk-dev-`, or `sk-local-`
|
|
193
|
-
- Check API key permissions and quota
|
|
194
|
-
- Try development mode: `OPTIMIZER_DEV_MODE=true`
|
|
195
|
-
|
|
196
|
-
**"Cross-platform script issues"**
|
|
197
|
-
- Ensure `cross-env` is installed: `npm install`
|
|
198
|
-
- Use platform-specific commands if needed:
|
|
199
|
-
- Windows: `npm run dev:windows`
|
|
200
|
-
- Unix/Mac: `npm run dev:unix`
|
|
201
|
-
|
|
202
|
-
### Debug Commands
|
|
203
|
-
|
|
204
|
-
```bash
|
|
205
|
-
# Verbose test output
|
|
206
|
-
DEBUG=* npm test
|
|
207
|
-
|
|
208
|
-
# Individual test suites
|
|
209
|
-
npm run test:quick
|
|
210
|
-
npm run test:integration
|
|
211
|
-
npm run test:comprehensive
|
|
212
|
-
|
|
213
|
-
# Test specific functionality
|
|
214
|
-
node lib/validate-key.js
|
|
215
|
-
node lib/diagnose.js
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
## ๐ Continuous Integration
|
|
219
|
-
|
|
220
|
-
For CI/CD pipelines, use:
|
|
221
|
-
|
|
222
|
-
```yaml
|
|
223
|
-
# GitHub Actions example
|
|
224
|
-
- name: Run tests
|
|
225
|
-
run: |
|
|
226
|
-
npm ci
|
|
227
|
-
npm run test:quick
|
|
228
|
-
env:
|
|
229
|
-
OPTIMIZER_DEV_MODE: true
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
The test suite is designed to work in CI environments without requiring real API keys.
|