mcp-prompt-optimizer 1.5.0 ā 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 +26 -9
- package/CROSS-PLATFORM.md +3 -3
- package/README.md +99 -39
- package/index.js +311 -130
- package/lib/api-key-manager.js +191 -138
- package/lib/check-status.js +1 -1
- package/package.json +3 -3
- 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 -282
- package/tests/simple-test.js +0 -171
- package/tests/test-runner.js +0 -322
package/tests/simple-test.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* š§ SIMPLE INTEGRATION TEST
|
|
5
|
-
*
|
|
6
|
-
* Simplified test that doesn't rely on MCP SDK to identify the core issue
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const path = require('path');
|
|
10
|
-
const fs = require('fs');
|
|
11
|
-
|
|
12
|
-
console.log('š§ Simple Integration Test - Debugging Module Issues\n');
|
|
13
|
-
|
|
14
|
-
// Test 1: Check if we're in the right directory
|
|
15
|
-
const currentDir = process.cwd();
|
|
16
|
-
console.log(`Current directory: ${currentDir}`);
|
|
17
|
-
|
|
18
|
-
// Test 2: Check if required files exist
|
|
19
|
-
const requiredFiles = [
|
|
20
|
-
'index.js',
|
|
21
|
-
'package.json',
|
|
22
|
-
'lib/api-key-manager.js'
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
console.log('\nš File Check:');
|
|
26
|
-
for (const file of requiredFiles) {
|
|
27
|
-
const exists = fs.existsSync(file);
|
|
28
|
-
console.log(` ${exists ? 'ā
' : 'ā'} ${file}`);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Test 3: Try to load package.json
|
|
32
|
-
console.log('\nš¦ Package.json Check:');
|
|
33
|
-
try {
|
|
34
|
-
const packageJson = require('./package.json');
|
|
35
|
-
console.log(` ā
Package loaded: ${packageJson.name} v${packageJson.version}`);
|
|
36
|
-
} catch (error) {
|
|
37
|
-
console.log(` ā Package.json error: ${error.message}`);
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Test 4: Try to load API Key Manager
|
|
42
|
-
console.log('\nš API Key Manager Check:');
|
|
43
|
-
try {
|
|
44
|
-
const CloudApiKeyManager = require('./lib/api-key-manager');
|
|
45
|
-
console.log(` ā
API Key Manager loaded: ${typeof CloudApiKeyManager}`);
|
|
46
|
-
|
|
47
|
-
// Test creating an instance
|
|
48
|
-
const manager = new CloudApiKeyManager('sk-dev-test-key-1234567890abcdef', { developmentMode: true });
|
|
49
|
-
console.log(` ā
Manager instance created`);
|
|
50
|
-
|
|
51
|
-
// Test format validation
|
|
52
|
-
const validation = manager.validateApiKeyFormat('sk-opt-1234567890abcdef1234567890');
|
|
53
|
-
console.log(` ā
Format validation works: ${validation.valid}`);
|
|
54
|
-
|
|
55
|
-
} catch (error) {
|
|
56
|
-
console.log(` ā API Key Manager error: ${error.message}`);
|
|
57
|
-
console.log(` Stack: ${error.stack}`);
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Test 5: Check MCP SDK availability
|
|
62
|
-
console.log('\nš MCP SDK Check:');
|
|
63
|
-
try {
|
|
64
|
-
const { Server } = require('@modelcontextprotocol/sdk/server/index.js');
|
|
65
|
-
console.log(` ā
MCP SDK loaded: ${typeof Server}`);
|
|
66
|
-
} catch (error) {
|
|
67
|
-
console.log(` ā MCP SDK error: ${error.message}`);
|
|
68
|
-
console.log(` This might be the issue - trying to install...`);
|
|
69
|
-
|
|
70
|
-
// Show npm install suggestion
|
|
71
|
-
console.log('\nš” Suggested fix:');
|
|
72
|
-
console.log(' npm install @modelcontextprotocol/sdk');
|
|
73
|
-
console.log(' npm install node-fetch');
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Test 6: Try to load main module (simplified)
|
|
77
|
-
console.log('\nš Main Module Check:');
|
|
78
|
-
try {
|
|
79
|
-
// Try to create a minimal version first
|
|
80
|
-
const https = require('https');
|
|
81
|
-
const CloudApiKeyManager = require('./lib/api-key-manager');
|
|
82
|
-
const packageJson = require('./package.json');
|
|
83
|
-
|
|
84
|
-
console.log(` ā
Core modules loaded`);
|
|
85
|
-
console.log(` ā
HTTPS available: ${typeof https.request}`);
|
|
86
|
-
console.log(` ā
Package info: ${packageJson.name}`);
|
|
87
|
-
|
|
88
|
-
// Try to create a mock optimizer without MCP SDK
|
|
89
|
-
class MockOptimizer {
|
|
90
|
-
constructor() {
|
|
91
|
-
this.backendUrl = 'https://p01--project-optimizer--fvmrdk8m9k9j.code.run';
|
|
92
|
-
this.apiKey = 'sk-dev-test-key';
|
|
93
|
-
this.developmentMode = true;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
detectAIContext(prompt) {
|
|
97
|
-
const p = prompt.toLowerCase();
|
|
98
|
-
if (/image|photo/i.test(p)) return 'image_generation';
|
|
99
|
-
if (/act as|you are/i.test(p)) return 'llm_interaction';
|
|
100
|
-
return 'human_communication';
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
generateMockOptimization(prompt, goals, aiContext) {
|
|
104
|
-
return {
|
|
105
|
-
optimized_prompt: `Optimized for ${aiContext}: ${prompt}`,
|
|
106
|
-
confidence_score: 0.87,
|
|
107
|
-
mock_mode: true
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
formatOptimizationResult(result, context) {
|
|
112
|
-
return `# šÆ Optimized Prompt\n\n${result.optimized_prompt}\n\n**Confidence:** ${(result.confidence_score * 100).toFixed(1)}%`;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const mockOptimizer = new MockOptimizer();
|
|
117
|
-
const context = mockOptimizer.detectAIContext('Help me write an email');
|
|
118
|
-
const mockResult = mockOptimizer.generateMockOptimization('Test prompt', ['clarity'], context);
|
|
119
|
-
const formatted = mockOptimizer.formatOptimizationResult(mockResult, { detectedContext: context });
|
|
120
|
-
|
|
121
|
-
console.log(` ā
Mock optimizer created and tested`);
|
|
122
|
-
console.log(` ā
AI context detection: ${context}`);
|
|
123
|
-
console.log(` ā
Mock optimization generated`);
|
|
124
|
-
|
|
125
|
-
} catch (error) {
|
|
126
|
-
console.log(` ā Main module error: ${error.message}`);
|
|
127
|
-
console.log(` Stack: ${error.stack}`);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Test 7: API Key Manager Validation
|
|
131
|
-
console.log('\nš§Ŗ API Key Manager Validation Test:');
|
|
132
|
-
try {
|
|
133
|
-
const CloudApiKeyManager = require('./lib/api-key-manager');
|
|
134
|
-
const manager = new CloudApiKeyManager('sk-dev-test-key-1234567890abcdef', { developmentMode: true });
|
|
135
|
-
|
|
136
|
-
// Test mock validation
|
|
137
|
-
manager.validateApiKey().then(validation => {
|
|
138
|
-
console.log(` ā
Mock validation successful: ${validation.valid}`);
|
|
139
|
-
console.log(` ā
Tier: ${validation.tier}`);
|
|
140
|
-
console.log(` ā
Mock mode: ${validation.mock_mode}`);
|
|
141
|
-
|
|
142
|
-
// All tests passed
|
|
143
|
-
console.log('\nš ALL CORE TESTS PASSED!');
|
|
144
|
-
console.log('\nš Summary:');
|
|
145
|
-
console.log(' ⢠Package structure is correct');
|
|
146
|
-
console.log(' ⢠API Key Manager works properly');
|
|
147
|
-
console.log(' ⢠Core functionality is operational');
|
|
148
|
-
console.log(' ⢠Mock mode is functional');
|
|
149
|
-
|
|
150
|
-
if (fs.existsSync('node_modules/@modelcontextprotocol')) {
|
|
151
|
-
console.log(' ⢠MCP SDK is installed');
|
|
152
|
-
console.log('\nā
Package is ready for publication!');
|
|
153
|
-
console.log('\nš You can safely run: npm publish');
|
|
154
|
-
} else {
|
|
155
|
-
console.log(' ⢠MCP SDK needs installation');
|
|
156
|
-
console.log('\nš” Run these commands first:');
|
|
157
|
-
console.log(' npm install');
|
|
158
|
-
console.log(' npm run test:quick');
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
process.exit(0);
|
|
162
|
-
|
|
163
|
-
}).catch(error => {
|
|
164
|
-
console.log(` ā Validation error: ${error.message}`);
|
|
165
|
-
process.exit(1);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
} catch (error) {
|
|
169
|
-
console.log(` ā Validation setup error: ${error.message}`);
|
|
170
|
-
process.exit(1);
|
|
171
|
-
}
|
package/tests/test-runner.js
DELETED
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* šÆ TEST RUNNER - MASTER TEST ORCHESTRATOR
|
|
5
|
-
*
|
|
6
|
-
* Runs all test suites in the optimal order for pre-publication validation.
|
|
7
|
-
* Provides comprehensive package verification before NPM registry publication.
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* - Full test suite: node tests/test-runner.js
|
|
11
|
-
* - Quick tests only: node tests/test-runner.js --quick
|
|
12
|
-
* - With API key: OPTIMIZER_API_KEY=sk-opt-xxx node tests/test-runner.js
|
|
13
|
-
* - Integration only: node tests/test-runner.js --integration
|
|
14
|
-
* - Comprehensive only: node tests/test-runner.js --comprehensive
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
const { spawn } = require('child_process');
|
|
18
|
-
const path = require('path');
|
|
19
|
-
const packageJson = require('../package.json');
|
|
20
|
-
|
|
21
|
-
class TestRunner {
|
|
22
|
-
constructor() {
|
|
23
|
-
this.testResults = {
|
|
24
|
-
quick: null,
|
|
25
|
-
integration: null,
|
|
26
|
-
comprehensive: null
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
this.args = process.argv.slice(2);
|
|
30
|
-
this.runQuickOnly = this.args.includes('--quick');
|
|
31
|
-
this.runIntegrationOnly = this.args.includes('--integration');
|
|
32
|
-
this.runComprehensiveOnly = this.args.includes('--comprehensive');
|
|
33
|
-
this.hasApiKey = !!process.env.OPTIMIZER_API_KEY;
|
|
34
|
-
|
|
35
|
-
this.startTime = Date.now();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
log(message, type = 'info') {
|
|
39
|
-
const timestamp = new Date().toLocaleTimeString();
|
|
40
|
-
const icons = {
|
|
41
|
-
success: 'ā
',
|
|
42
|
-
error: 'ā',
|
|
43
|
-
warning: 'ā ļø',
|
|
44
|
-
info: 'ā¹ļø',
|
|
45
|
-
runner: 'šÆ',
|
|
46
|
-
start: 'š',
|
|
47
|
-
complete: 'š'
|
|
48
|
-
};
|
|
49
|
-
console.log(`[${timestamp}] ${icons[type] || icons.info} ${message}`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
getTestMode() {
|
|
53
|
-
if (this.runQuickOnly) return 'Quick Only';
|
|
54
|
-
if (this.runIntegrationOnly) return 'Integration Only';
|
|
55
|
-
if (this.runComprehensiveOnly) return 'Comprehensive Only';
|
|
56
|
-
return 'Full Test Suite';
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async runTest(testName, scriptPath) {
|
|
60
|
-
return new Promise((resolve) => {
|
|
61
|
-
this.log(`Starting ${testName} test suite...`, 'start');
|
|
62
|
-
|
|
63
|
-
const child = spawn('node', [scriptPath], {
|
|
64
|
-
cwd: path.join(__dirname, '..'),
|
|
65
|
-
env: { ...process.env },
|
|
66
|
-
stdio: 'inherit'
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
child.on('close', (code) => {
|
|
70
|
-
const success = code === 0;
|
|
71
|
-
this.testResults[testName] = success;
|
|
72
|
-
|
|
73
|
-
if (success) {
|
|
74
|
-
this.log(`${testName} test suite completed successfully`, 'success');
|
|
75
|
-
} else {
|
|
76
|
-
this.log(`${testName} test suite failed with exit code ${code}`, 'error');
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
resolve(success);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
child.on('error', (error) => {
|
|
83
|
-
this.log(`${testName} test suite error: ${error.message}`, 'error');
|
|
84
|
-
this.testResults[testName] = false;
|
|
85
|
-
resolve(false);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async runAllTests() {
|
|
91
|
-
console.log('='.repeat(100));
|
|
92
|
-
console.log('šÆ TEST RUNNER - COMPREHENSIVE PACKAGE VALIDATION');
|
|
93
|
-
console.log('='.repeat(100));
|
|
94
|
-
console.log(`š¦ Package: ${packageJson.name} v${packageJson.version}`);
|
|
95
|
-
console.log(`š API Key: ${this.hasApiKey ? 'Available' : 'Mock Mode'}`);
|
|
96
|
-
console.log(`āļø Test Mode: ${this.getTestMode()}`);
|
|
97
|
-
console.log(`š
Started: ${new Date().toLocaleString()}`);
|
|
98
|
-
console.log('='.repeat(100) + '\n');
|
|
99
|
-
|
|
100
|
-
let allTestsPassed = true;
|
|
101
|
-
|
|
102
|
-
try {
|
|
103
|
-
// Quick Tests (always run first unless specifically excluded)
|
|
104
|
-
if (!this.runIntegrationOnly && !this.runComprehensiveOnly) {
|
|
105
|
-
const quickSuccess = await this.runTest('quick', 'tests/quick-test.js');
|
|
106
|
-
allTestsPassed = allTestsPassed && quickSuccess;
|
|
107
|
-
|
|
108
|
-
if (!quickSuccess && this.runQuickOnly) {
|
|
109
|
-
this.log('Quick tests failed - stopping execution', 'error');
|
|
110
|
-
this.generateFinalReport();
|
|
111
|
-
return allTestsPassed;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
console.log('\n' + '-'.repeat(80) + '\n');
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Integration Tests
|
|
118
|
-
if (!this.runQuickOnly && !this.runComprehensiveOnly) {
|
|
119
|
-
const integrationSuccess = await this.runTest('integration', 'tests/integration-test.js');
|
|
120
|
-
allTestsPassed = allTestsPassed && integrationSuccess;
|
|
121
|
-
|
|
122
|
-
if (this.runIntegrationOnly) {
|
|
123
|
-
this.generateFinalReport();
|
|
124
|
-
return allTestsPassed;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
console.log('\n' + '-'.repeat(80) + '\n');
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Comprehensive Tests (only if other tests passed or specifically requested)
|
|
131
|
-
if (!this.runQuickOnly && !this.runIntegrationOnly) {
|
|
132
|
-
if (allTestsPassed || this.runComprehensiveOnly) {
|
|
133
|
-
const comprehensiveSuccess = await this.runTest('comprehensive', 'tests/comprehensive-test.js');
|
|
134
|
-
allTestsPassed = allTestsPassed && comprehensiveSuccess;
|
|
135
|
-
} else {
|
|
136
|
-
this.log('Skipping comprehensive tests due to earlier failures', 'warning');
|
|
137
|
-
this.testResults.comprehensive = 'skipped';
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
} catch (error) {
|
|
142
|
-
this.log(`Test runner error: ${error.message}`, 'error');
|
|
143
|
-
allTestsPassed = false;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
this.generateFinalReport();
|
|
147
|
-
return allTestsPassed;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
generateFinalReport() {
|
|
151
|
-
const duration = ((Date.now() - this.startTime) / 1000).toFixed(2);
|
|
152
|
-
|
|
153
|
-
console.log('\n' + '='.repeat(100));
|
|
154
|
-
console.log('š FINAL TEST RUNNER REPORT');
|
|
155
|
-
console.log('='.repeat(100));
|
|
156
|
-
|
|
157
|
-
console.log(`š¦ Package: ${packageJson.name} v${packageJson.version}`);
|
|
158
|
-
console.log(`ā±ļø Total Duration: ${duration} seconds`);
|
|
159
|
-
console.log(`š API Key: ${this.hasApiKey ? 'Available' : 'Mock Mode'}`);
|
|
160
|
-
console.log(`āļø Test Mode: ${this.getTestMode()}`);
|
|
161
|
-
console.log();
|
|
162
|
-
|
|
163
|
-
// Test Results Summary
|
|
164
|
-
console.log('š TEST SUITE RESULTS:');
|
|
165
|
-
Object.entries(this.testResults).forEach(([testName, result]) => {
|
|
166
|
-
if (result === null) {
|
|
167
|
-
console.log(` āŖ ${testName.toUpperCase()}: Not Run`);
|
|
168
|
-
} else if (result === 'skipped') {
|
|
169
|
-
console.log(` ā ļø ${testName.toUpperCase()}: Skipped`);
|
|
170
|
-
} else if (result === true) {
|
|
171
|
-
console.log(` ā
${testName.toUpperCase()}: PASSED`);
|
|
172
|
-
} else {
|
|
173
|
-
console.log(` ā ${testName.toUpperCase()}: FAILED`);
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
const passedTests = Object.values(this.testResults).filter(r => r === true).length;
|
|
178
|
-
const failedTests = Object.values(this.testResults).filter(r => r === false).length;
|
|
179
|
-
const totalTests = Object.values(this.testResults).filter(r => r !== null && r !== 'skipped').length;
|
|
180
|
-
const successRate = totalTests > 0 ? ((passedTests / totalTests) * 100).toFixed(1) : 0;
|
|
181
|
-
|
|
182
|
-
console.log();
|
|
183
|
-
console.log('š OVERALL SUMMARY:');
|
|
184
|
-
console.log(` ā
Passed: ${passedTests}`);
|
|
185
|
-
console.log(` ā Failed: ${failedTests}`);
|
|
186
|
-
console.log(` š Success Rate: ${successRate}%`);
|
|
187
|
-
|
|
188
|
-
// Publication Readiness Assessment
|
|
189
|
-
console.log();
|
|
190
|
-
console.log('š PUBLICATION READINESS:');
|
|
191
|
-
|
|
192
|
-
const allTestsPassed = failedTests === 0;
|
|
193
|
-
const hasQuickTests = this.testResults.quick === true;
|
|
194
|
-
const hasIntegrationTests = this.testResults.integration === true || this.testResults.integration === null;
|
|
195
|
-
|
|
196
|
-
if (allTestsPassed && hasQuickTests) {
|
|
197
|
-
console.log('ā
READY FOR NPM PUBLICATION');
|
|
198
|
-
console.log();
|
|
199
|
-
console.log('š All critical tests passed successfully!');
|
|
200
|
-
console.log(' Your package is ready for production deployment.');
|
|
201
|
-
|
|
202
|
-
if (!this.hasApiKey) {
|
|
203
|
-
console.log();
|
|
204
|
-
console.log('š NOTE: Tests ran in mock mode.');
|
|
205
|
-
console.log(' Consider testing with a real API key for full validation:');
|
|
206
|
-
console.log(' OPTIMIZER_API_KEY=sk-opt-xxx node tests/test-runner.js');
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
console.log();
|
|
210
|
-
console.log('š RECOMMENDED PUBLICATION COMMANDS:');
|
|
211
|
-
console.log(' npm publish # Publish to NPM registry');
|
|
212
|
-
console.log(` git tag v${packageJson.version} # Tag the release`);
|
|
213
|
-
console.log(' git push --tags # Push tags to repository');
|
|
214
|
-
console.log(' npm pack # Create package for testing');
|
|
215
|
-
|
|
216
|
-
} else {
|
|
217
|
-
console.log('ā NOT READY FOR PUBLICATION');
|
|
218
|
-
console.log();
|
|
219
|
-
console.log('š§ ISSUES TO RESOLVE:');
|
|
220
|
-
|
|
221
|
-
if (!hasQuickTests) {
|
|
222
|
-
console.log(' ⢠Quick tests must pass before publication');
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (failedTests > 0) {
|
|
226
|
-
console.log(' ⢠Fix all failed tests before proceeding');
|
|
227
|
-
console.log(' ⢠Run individual test suites to debug specific issues:');
|
|
228
|
-
console.log(' - node tests/quick-test.js');
|
|
229
|
-
console.log(' - node tests/integration-test.js');
|
|
230
|
-
console.log(' - node tests/comprehensive-test.js');
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// Additional Recommendations
|
|
235
|
-
console.log();
|
|
236
|
-
console.log('š” ADDITIONAL RECOMMENDATIONS:');
|
|
237
|
-
|
|
238
|
-
if (this.runQuickOnly) {
|
|
239
|
-
console.log(' ⢠Run full test suite for comprehensive validation:');
|
|
240
|
-
console.log(' node tests/test-runner.js');
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (!this.hasApiKey && allTestsPassed) {
|
|
244
|
-
console.log(' ⢠Test with real API key for production readiness:');
|
|
245
|
-
console.log(' OPTIMIZER_API_KEY=your-key node tests/test-runner.js');
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
console.log(' ⢠Review package.json for version increment if needed');
|
|
249
|
-
console.log(' ⢠Update CHANGELOG.md with release notes');
|
|
250
|
-
console.log(' ⢠Verify README.md is current and comprehensive');
|
|
251
|
-
|
|
252
|
-
console.log();
|
|
253
|
-
console.log('='.repeat(100));
|
|
254
|
-
console.log(`Test runner completed at ${new Date().toLocaleString()}`);
|
|
255
|
-
console.log('='.repeat(100));
|
|
256
|
-
|
|
257
|
-
return allTestsPassed;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// Help text
|
|
262
|
-
function showHelp() {
|
|
263
|
-
console.log(`
|
|
264
|
-
šÆ MCP Prompt Optimizer Test Runner
|
|
265
|
-
|
|
266
|
-
USAGE:
|
|
267
|
-
node tests/test-runner.js [options]
|
|
268
|
-
|
|
269
|
-
OPTIONS:
|
|
270
|
-
--quick Run only quick tests (fastest validation)
|
|
271
|
-
--integration Run only integration tests (API connectivity)
|
|
272
|
-
--comprehensive Run only comprehensive tests (detailed analysis)
|
|
273
|
-
--help Show this help message
|
|
274
|
-
|
|
275
|
-
EXAMPLES:
|
|
276
|
-
# Full test suite (recommended)
|
|
277
|
-
node tests/test-runner.js
|
|
278
|
-
|
|
279
|
-
# Quick validation only
|
|
280
|
-
node tests/test-runner.js --quick
|
|
281
|
-
|
|
282
|
-
# With real API key
|
|
283
|
-
OPTIMIZER_API_KEY=sk-opt-xxx node tests/test-runner.js
|
|
284
|
-
|
|
285
|
-
# Integration tests only
|
|
286
|
-
node tests/test-runner.js --integration
|
|
287
|
-
|
|
288
|
-
ENVIRONMENT VARIABLES:
|
|
289
|
-
OPTIMIZER_API_KEY Real API key for full testing
|
|
290
|
-
OPTIMIZER_DEV_MODE Enable development mode (true/false)
|
|
291
|
-
OPTIMIZER_BACKEND_URL Custom backend URL for testing
|
|
292
|
-
|
|
293
|
-
TEST SUITES:
|
|
294
|
-
Quick Tests - Package structure, basic functionality (~30 seconds)
|
|
295
|
-
Integration Tests - API connectivity, real backend testing (~60 seconds)
|
|
296
|
-
Comprehensive - Full feature testing, error scenarios (~120 seconds)
|
|
297
|
-
|
|
298
|
-
For more information, visit: https://promptoptimizer-blog.vercel.app/docs
|
|
299
|
-
`);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// Main execution
|
|
303
|
-
if (require.main === module) {
|
|
304
|
-
const args = process.argv.slice(2);
|
|
305
|
-
|
|
306
|
-
if (args.includes('--help') || args.includes('-h')) {
|
|
307
|
-
showHelp();
|
|
308
|
-
process.exit(0);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
const testRunner = new TestRunner();
|
|
312
|
-
testRunner.runAllTests()
|
|
313
|
-
.then(success => {
|
|
314
|
-
process.exit(success ? 0 : 1);
|
|
315
|
-
})
|
|
316
|
-
.catch(error => {
|
|
317
|
-
console.error('ā Test runner crashed:', error);
|
|
318
|
-
process.exit(1);
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
module.exports = TestRunner;
|