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/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.