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/minimal-test.js
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ๐งช MINIMAL INTEGRATION TEST
|
|
5
|
-
*
|
|
6
|
-
* Simplified integration test that tests core functionality without MCP SDK complications
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const https = require('https');
|
|
10
|
-
const http = require('http');
|
|
11
|
-
|
|
12
|
-
class MinimalIntegrationTest {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.results = { passed: 0, failed: 0, errors: [] };
|
|
15
|
-
this.backendUrl = 'https://p01--project-optimizer--fvmrdk8m9k9j.code.run';
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
log(message, type = 'info') {
|
|
19
|
-
const icons = { success: 'โ
', error: 'โ', info: 'โน๏ธ', test: '๐งช' };
|
|
20
|
-
console.log(`${icons[type] || icons.info} ${message}`);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async test(name, testFn) {
|
|
24
|
-
try {
|
|
25
|
-
this.log(`Testing: ${name}`, 'test');
|
|
26
|
-
const result = await testFn();
|
|
27
|
-
|
|
28
|
-
if (result.success) {
|
|
29
|
-
this.results.passed++;
|
|
30
|
-
this.log(`PASS: ${name}`, 'success');
|
|
31
|
-
if (result.details) this.log(` ${result.details}`, 'info');
|
|
32
|
-
} else {
|
|
33
|
-
this.results.failed++;
|
|
34
|
-
this.results.errors.push(name);
|
|
35
|
-
this.log(`FAIL: ${name}`, 'error');
|
|
36
|
-
if (result.error) this.log(` ${result.error}`, 'error');
|
|
37
|
-
}
|
|
38
|
-
} catch (error) {
|
|
39
|
-
this.results.failed++;
|
|
40
|
-
this.results.errors.push(name);
|
|
41
|
-
this.log(`FAIL: ${name} - ${error.message}`, 'error');
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Test 1: Package structure
|
|
46
|
-
async testPackageStructure() {
|
|
47
|
-
try {
|
|
48
|
-
const fs = require('fs');
|
|
49
|
-
const packageJson = require('../package.json');
|
|
50
|
-
|
|
51
|
-
const requiredFiles = ['index.js', 'lib/api-key-manager.js', 'package.json'];
|
|
52
|
-
const filesExist = requiredFiles.every(file => fs.existsSync(file));
|
|
53
|
-
|
|
54
|
-
if (filesExist && packageJson.name === 'mcp-prompt-optimizer') {
|
|
55
|
-
return {
|
|
56
|
-
success: true,
|
|
57
|
-
details: `Package: ${packageJson.name} v${packageJson.version}`
|
|
58
|
-
};
|
|
59
|
-
} else {
|
|
60
|
-
return {
|
|
61
|
-
success: false,
|
|
62
|
-
error: 'Missing required files or incorrect package name'
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
} catch (error) {
|
|
66
|
-
return { success: false, error: error.message };
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Test 2: API Key Manager
|
|
71
|
-
async testApiKeyManager() {
|
|
72
|
-
try {
|
|
73
|
-
const CloudApiKeyManager = require('../lib/api-key-manager');
|
|
74
|
-
const manager = new CloudApiKeyManager('sk-dev-test-key-1234567890abcdef', {
|
|
75
|
-
developmentMode: true
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
const validation = manager.validateApiKeyFormat('sk-opt-1234567890abcdef1234567890');
|
|
79
|
-
|
|
80
|
-
if (validation.valid) {
|
|
81
|
-
return {
|
|
82
|
-
success: true,
|
|
83
|
-
details: 'API key format validation working'
|
|
84
|
-
};
|
|
85
|
-
} else {
|
|
86
|
-
return {
|
|
87
|
-
success: false,
|
|
88
|
-
error: 'API key format validation failed'
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
} catch (error) {
|
|
92
|
-
return { success: false, error: error.message };
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Test 3: Mock API validation
|
|
97
|
-
async testMockApiValidation() {
|
|
98
|
-
try {
|
|
99
|
-
const CloudApiKeyManager = require('../lib/api-key-manager');
|
|
100
|
-
const manager = new CloudApiKeyManager('sk-dev-test-key-1234567890abcdef', {
|
|
101
|
-
developmentMode: true
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
const validation = await manager.validateApiKey();
|
|
105
|
-
|
|
106
|
-
if (validation && validation.valid && validation.mock_mode) {
|
|
107
|
-
return {
|
|
108
|
-
success: true,
|
|
109
|
-
details: `Mock validation successful, tier: ${validation.tier}`
|
|
110
|
-
};
|
|
111
|
-
} else {
|
|
112
|
-
return {
|
|
113
|
-
success: false,
|
|
114
|
-
error: 'Mock validation did not return expected structure'
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
} catch (error) {
|
|
118
|
-
return { success: false, error: error.message };
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Test 4: Backend connectivity
|
|
123
|
-
async testBackendConnectivity() {
|
|
124
|
-
return new Promise((resolve) => {
|
|
125
|
-
const url = `${this.backendUrl}/health`;
|
|
126
|
-
const client = this.backendUrl.startsWith('https://') ? https : http;
|
|
127
|
-
|
|
128
|
-
const req = client.request(url, { method: 'GET', timeout: 5000 }, (res) => {
|
|
129
|
-
if (res.statusCode === 200) {
|
|
130
|
-
resolve({
|
|
131
|
-
success: true,
|
|
132
|
-
details: `Backend responded with status ${res.statusCode}`
|
|
133
|
-
});
|
|
134
|
-
} else {
|
|
135
|
-
resolve({
|
|
136
|
-
success: false,
|
|
137
|
-
error: `Backend returned status ${res.statusCode}`
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
req.on('error', (error) => {
|
|
143
|
-
resolve({
|
|
144
|
-
success: false,
|
|
145
|
-
error: `Backend connection failed: ${error.message}`
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
req.on('timeout', () => {
|
|
150
|
-
req.destroy();
|
|
151
|
-
resolve({
|
|
152
|
-
success: false,
|
|
153
|
-
error: 'Backend connection timeout'
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
req.setTimeout(5000);
|
|
158
|
-
req.end();
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Test 5: Core functionality without MCP SDK
|
|
163
|
-
async testCoreFunctionality() {
|
|
164
|
-
try {
|
|
165
|
-
// Mock the core functions that would be in the main class
|
|
166
|
-
const detectAIContext = (prompt) => {
|
|
167
|
-
const p = prompt.toLowerCase();
|
|
168
|
-
if (/image|photo/i.test(p)) return 'image_generation';
|
|
169
|
-
if (/act as|you are/i.test(p)) return 'llm_interaction';
|
|
170
|
-
return 'human_communication';
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
const generateMockOptimization = (prompt, goals, aiContext) => {
|
|
174
|
-
return {
|
|
175
|
-
optimized_prompt: `Optimized for ${aiContext}: ${prompt}`,
|
|
176
|
-
confidence_score: 0.87,
|
|
177
|
-
mock_mode: true
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
// Test AI context detection
|
|
182
|
-
const context1 = detectAIContext('Create a photorealistic image');
|
|
183
|
-
const context2 = detectAIContext('You are a helpful assistant');
|
|
184
|
-
const context3 = detectAIContext('Help me write an email');
|
|
185
|
-
|
|
186
|
-
// Test mock optimization
|
|
187
|
-
const mockResult = generateMockOptimization('Test prompt', ['clarity'], 'llm_interaction');
|
|
188
|
-
|
|
189
|
-
if (context1 === 'image_generation' &&
|
|
190
|
-
context2 === 'llm_interaction' &&
|
|
191
|
-
context3 === 'human_communication' &&
|
|
192
|
-
mockResult.optimized_prompt &&
|
|
193
|
-
mockResult.confidence_score === 0.87) {
|
|
194
|
-
|
|
195
|
-
return {
|
|
196
|
-
success: true,
|
|
197
|
-
details: 'Core AI functionality working correctly'
|
|
198
|
-
};
|
|
199
|
-
} else {
|
|
200
|
-
return {
|
|
201
|
-
success: false,
|
|
202
|
-
error: 'Core functionality tests failed'
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
} catch (error) {
|
|
206
|
-
return { success: false, error: error.message };
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
async runTests() {
|
|
211
|
-
console.log('๐งช Minimal Integration Test Suite\n');
|
|
212
|
-
|
|
213
|
-
await this.test('Package Structure', () => this.testPackageStructure());
|
|
214
|
-
await this.test('API Key Manager', () => this.testApiKeyManager());
|
|
215
|
-
await this.test('Mock API Validation', () => this.testMockApiValidation());
|
|
216
|
-
await this.test('Backend Connectivity', () => this.testBackendConnectivity());
|
|
217
|
-
await this.test('Core Functionality', () => this.testCoreFunctionality());
|
|
218
|
-
|
|
219
|
-
this.generateReport();
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
generateReport() {
|
|
223
|
-
const total = this.results.passed + this.results.failed;
|
|
224
|
-
const successRate = total > 0 ? ((this.results.passed / total) * 100).toFixed(1) : 0;
|
|
225
|
-
|
|
226
|
-
console.log('\n' + '='.repeat(60));
|
|
227
|
-
console.log('๐งช MINIMAL INTEGRATION TEST RESULTS');
|
|
228
|
-
console.log('='.repeat(60));
|
|
229
|
-
|
|
230
|
-
console.log(`โ
Tests Passed: ${this.results.passed}`);
|
|
231
|
-
console.log(`โ Tests Failed: ${this.results.failed}`);
|
|
232
|
-
console.log(`๐ Success Rate: ${successRate}%`);
|
|
233
|
-
|
|
234
|
-
if (this.results.failed > 0) {
|
|
235
|
-
console.log('\nโ FAILED TESTS:');
|
|
236
|
-
this.results.errors.forEach(error => console.log(` โข ${error}`));
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
console.log('\n๐ฏ STATUS:');
|
|
240
|
-
if (this.results.failed === 0) {
|
|
241
|
-
console.log('โ
CORE FUNCTIONALITY TESTS PASSED');
|
|
242
|
-
console.log(' Package core features are working correctly');
|
|
243
|
-
console.log(' Ready for publication testing');
|
|
244
|
-
} else {
|
|
245
|
-
console.log('โ SOME CORE TESTS FAILED');
|
|
246
|
-
console.log(' Review failed tests before proceeding');
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
console.log('='.repeat(60) + '\n');
|
|
250
|
-
return this.results.failed === 0;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// Run minimal integration tests
|
|
255
|
-
if (require.main === module) {
|
|
256
|
-
const test = new MinimalIntegrationTest();
|
|
257
|
-
test.runTests().then(success => {
|
|
258
|
-
process.exit(success ? 0 : 1);
|
|
259
|
-
}).catch(error => {
|
|
260
|
-
console.error('โ Test suite crashed:', error);
|
|
261
|
-
process.exit(1);
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
module.exports = MinimalIntegrationTest;
|
package/tests/quick-test.js
DELETED
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ๐ QUICK PRE-PUBLICATION TEST
|
|
5
|
-
*
|
|
6
|
-
* Fast validation script for immediate feedback before NPM publication.
|
|
7
|
-
* Tests core functionality without requiring API keys.
|
|
8
|
-
*
|
|
9
|
-
* Usage: node tests/quick-test.js
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const fs = require('fs');
|
|
13
|
-
const path = require('path');
|
|
14
|
-
const { MCPPromptOptimizer } = require('../index');
|
|
15
|
-
const CloudApiKeyManager = require('../lib/api-key-manager');
|
|
16
|
-
const packageJson = require('../package.json');
|
|
17
|
-
|
|
18
|
-
class QuickTest {
|
|
19
|
-
constructor() {
|
|
20
|
-
this.passed = 0;
|
|
21
|
-
this.failed = 0;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
test(name, condition, details = '') {
|
|
25
|
-
if (condition) {
|
|
26
|
-
this.passed++;
|
|
27
|
-
console.log(`โ
${name}`);
|
|
28
|
-
if (details) console.log(` ${details}`);
|
|
29
|
-
} else {
|
|
30
|
-
this.failed++;
|
|
31
|
-
console.log(`โ ${name}`);
|
|
32
|
-
if (details) console.log(` ${details}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async run() {
|
|
37
|
-
console.log(`๐ Quick Pre-Publication Test - ${packageJson.name} v${packageJson.version}\n`);
|
|
38
|
-
|
|
39
|
-
// 1. Package Structure
|
|
40
|
-
this.test(
|
|
41
|
-
'Package structure',
|
|
42
|
-
fs.existsSync('index.js') && fs.existsSync('package.json') && fs.existsSync('lib/api-key-manager.js'),
|
|
43
|
-
'All required files present'
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
// 2. Package.json validation
|
|
47
|
-
this.test(
|
|
48
|
-
'Package.json validity',
|
|
49
|
-
packageJson.name === 'mcp-prompt-optimizer' && packageJson.version && packageJson.main === 'index.js',
|
|
50
|
-
`Name: ${packageJson.name}, Version: ${packageJson.version}`
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
// 3. Cross-platform support
|
|
54
|
-
this.test(
|
|
55
|
-
'Cross-platform configuration',
|
|
56
|
-
Array.isArray(packageJson.os) && Array.isArray(packageJson.cpu) && packageJson.devDependencies['cross-env'],
|
|
57
|
-
'OS/CPU arrays defined, cross-env available'
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
// 4. Dependencies
|
|
61
|
-
this.test(
|
|
62
|
-
'Required dependencies',
|
|
63
|
-
packageJson.dependencies['@modelcontextprotocol/sdk'] && packageJson.dependencies['node-fetch'],
|
|
64
|
-
'MCP SDK and node-fetch present'
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
// 5. MCP Server Creation
|
|
68
|
-
try {
|
|
69
|
-
const server = new MCPPromptOptimizer();
|
|
70
|
-
this.test(
|
|
71
|
-
'MCP Server instantiation',
|
|
72
|
-
server && server.server && typeof server.backendUrl === 'string',
|
|
73
|
-
`Backend URL: ${server.backendUrl}`
|
|
74
|
-
);
|
|
75
|
-
} catch (error) {
|
|
76
|
-
this.test('MCP Server instantiation', false, error.message);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// 6. API Key Manager Creation
|
|
80
|
-
try {
|
|
81
|
-
const manager = new CloudApiKeyManager('sk-dev-test-key-1234567890abcdef', { developmentMode: true });
|
|
82
|
-
this.test(
|
|
83
|
-
'API Key Manager instantiation',
|
|
84
|
-
manager && typeof manager.validateApiKeyFormat === 'function',
|
|
85
|
-
'Manager created with development key'
|
|
86
|
-
);
|
|
87
|
-
} catch (error) {
|
|
88
|
-
this.test('API Key Manager instantiation', false, error.message);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// 7. API Key Format Validation
|
|
92
|
-
try {
|
|
93
|
-
const manager = new CloudApiKeyManager('dummy');
|
|
94
|
-
const validKey = manager.validateApiKeyFormat('sk-opt-1234567890abcdef1234567890');
|
|
95
|
-
const invalidKey = manager.validateApiKeyFormat('invalid-key');
|
|
96
|
-
|
|
97
|
-
this.test(
|
|
98
|
-
'API Key format validation',
|
|
99
|
-
validKey.valid === true && invalidKey.valid === false,
|
|
100
|
-
'Valid keys accepted, invalid keys rejected'
|
|
101
|
-
);
|
|
102
|
-
} catch (error) {
|
|
103
|
-
this.test('API Key format validation', false, error.message);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// 8. AI Context Detection - UPDATED with better test cases
|
|
107
|
-
try {
|
|
108
|
-
const server = new MCPPromptOptimizer();
|
|
109
|
-
const imageContext = server.detectAIContext('Create a photorealistic image with --ar 16:9 cinematic style');
|
|
110
|
-
const llmContext = server.detectAIContext('Analyze the pros and cons of this research paper and provide a comprehensive evaluation');
|
|
111
|
-
const codeContext = server.detectAIContext('def fibonacci(n): return n if n <= 1 else fibonacci(n-1) + fibonacci(n-2)');
|
|
112
|
-
|
|
113
|
-
const imageCorrect = imageContext === 'image_generation';
|
|
114
|
-
const llmCorrect = llmContext === 'llm_interaction';
|
|
115
|
-
const codeCorrect = codeContext === 'code_generation';
|
|
116
|
-
|
|
117
|
-
this.test(
|
|
118
|
-
'AI Context detection',
|
|
119
|
-
imageCorrect && llmCorrect && codeCorrect,
|
|
120
|
-
`Image: ${imageContext} โ, LLM: ${llmContext} โ, Code: ${codeContext} โ`
|
|
121
|
-
);
|
|
122
|
-
} catch (error) {
|
|
123
|
-
this.test('AI Context detection', false, error.message);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// 9. Goal Enhancement
|
|
127
|
-
try {
|
|
128
|
-
const server = new MCPPromptOptimizer();
|
|
129
|
-
const enhanced = server.enhanceGoalsForContext(['clarity'], 'image_generation');
|
|
130
|
-
|
|
131
|
-
this.test(
|
|
132
|
-
'Goal enhancement',
|
|
133
|
-
Array.isArray(enhanced) && enhanced.length > 1 && enhanced.includes('clarity'),
|
|
134
|
-
`Enhanced goals: ${enhanced.join(', ')}`
|
|
135
|
-
);
|
|
136
|
-
} catch (error) {
|
|
137
|
-
this.test('Goal enhancement', false, error.message);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// 10. Mock Optimization Generation
|
|
141
|
-
try {
|
|
142
|
-
const server = new MCPPromptOptimizer();
|
|
143
|
-
const mockResult = server.generateMockOptimization('Test prompt', ['clarity'], 'llm_interaction');
|
|
144
|
-
|
|
145
|
-
this.test(
|
|
146
|
-
'Mock optimization generation',
|
|
147
|
-
mockResult && mockResult.optimized_prompt && mockResult.confidence_score && mockResult.mock_mode,
|
|
148
|
-
`Generated mock with confidence: ${mockResult.confidence_score}`
|
|
149
|
-
);
|
|
150
|
-
} catch (error) {
|
|
151
|
-
this.test('Mock optimization generation', false, error.message);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// 11. Response Formatting
|
|
155
|
-
try {
|
|
156
|
-
const server = new MCPPromptOptimizer();
|
|
157
|
-
const mockResult = server.generateMockOptimization('Test', ['clarity'], 'llm_interaction');
|
|
158
|
-
const formatted = server.formatOptimizationResult(mockResult, { detectedContext: 'llm_interaction' });
|
|
159
|
-
|
|
160
|
-
this.test(
|
|
161
|
-
'Response formatting',
|
|
162
|
-
typeof formatted === 'string' && formatted.includes('๐ฏ Optimized Prompt') && formatted.includes('Confidence:'),
|
|
163
|
-
'Proper markdown formatting with emojis'
|
|
164
|
-
);
|
|
165
|
-
} catch (error) {
|
|
166
|
-
this.test('Response formatting', false, error.message);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// 12. CLI Commands Exist
|
|
170
|
-
const cliCommands = [
|
|
171
|
-
'lib/validate-key.js',
|
|
172
|
-
'lib/check-status.js',
|
|
173
|
-
'lib/clear-cache.js',
|
|
174
|
-
'lib/diagnose.js'
|
|
175
|
-
];
|
|
176
|
-
|
|
177
|
-
const cliExists = cliCommands.every(cmd => fs.existsSync(cmd));
|
|
178
|
-
this.test(
|
|
179
|
-
'CLI commands present',
|
|
180
|
-
cliExists,
|
|
181
|
-
`Commands: ${cliCommands.join(', ')}`
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
// 13. Environment Variable Support
|
|
185
|
-
try {
|
|
186
|
-
process.env.OPTIMIZER_BACKEND_URL = 'https://test.example.com';
|
|
187
|
-
process.env.OPTIMIZER_DEV_MODE = 'true';
|
|
188
|
-
|
|
189
|
-
const server = new MCPPromptOptimizer();
|
|
190
|
-
const urlCorrect = server.backendUrl === 'https://test.example.com';
|
|
191
|
-
const devModeCorrect = server.developmentMode === true;
|
|
192
|
-
|
|
193
|
-
this.test(
|
|
194
|
-
'Environment variable support',
|
|
195
|
-
urlCorrect && devModeCorrect,
|
|
196
|
-
'Backend URL and dev mode properly read from env vars'
|
|
197
|
-
);
|
|
198
|
-
|
|
199
|
-
// Cleanup
|
|
200
|
-
delete process.env.OPTIMIZER_BACKEND_URL;
|
|
201
|
-
delete process.env.OPTIMIZER_DEV_MODE;
|
|
202
|
-
} catch (error) {
|
|
203
|
-
this.test('Environment variable support', false, error.message);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// 14. NPM Scripts Validation
|
|
207
|
-
const requiredScripts = ['start', 'dev', 'check-status', 'validate-key', 'clear-cache', 'diagnose'];
|
|
208
|
-
const scriptsExist = requiredScripts.every(script => packageJson.scripts[script]);
|
|
209
|
-
|
|
210
|
-
this.test(
|
|
211
|
-
'NPM scripts defined',
|
|
212
|
-
scriptsExist,
|
|
213
|
-
`Required scripts: ${requiredScripts.join(', ')}`
|
|
214
|
-
);
|
|
215
|
-
|
|
216
|
-
// 15. Binary Definition
|
|
217
|
-
this.test(
|
|
218
|
-
'Binary configuration',
|
|
219
|
-
packageJson.bin && packageJson.bin['mcp-prompt-optimizer'] === 'index.js',
|
|
220
|
-
'Binary points to index.js'
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
// 16. NEW: Feature Flag Support
|
|
224
|
-
try {
|
|
225
|
-
process.env.ENABLE_BAYESIAN_OPTIMIZATION = 'false';
|
|
226
|
-
process.env.ENABLE_AGUI_FEATURES = 'false';
|
|
227
|
-
|
|
228
|
-
const server = new MCPPromptOptimizer();
|
|
229
|
-
const bayesianDisabled = server.bayesianOptimizationEnabled === false;
|
|
230
|
-
const aguiDisabled = server.aguiFeatures === false;
|
|
231
|
-
|
|
232
|
-
this.test(
|
|
233
|
-
'Feature flag support',
|
|
234
|
-
bayesianDisabled && aguiDisabled,
|
|
235
|
-
'Feature flags properly disable features'
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
// Cleanup
|
|
239
|
-
delete process.env.ENABLE_BAYESIAN_OPTIMIZATION;
|
|
240
|
-
delete process.env.ENABLE_AGUI_FEATURES;
|
|
241
|
-
} catch (error) {
|
|
242
|
-
this.test('Feature flag support', false, error.message);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// Report Results
|
|
246
|
-
console.log('\n' + '='.repeat(60));
|
|
247
|
-
console.log('๐ QUICK TEST RESULTS');
|
|
248
|
-
console.log('='.repeat(60));
|
|
249
|
-
console.log(`โ
Passed: ${this.passed}`);
|
|
250
|
-
console.log(`โ Failed: ${this.failed}`);
|
|
251
|
-
console.log(`๐ Success Rate: ${((this.passed / (this.passed + this.failed)) * 100).toFixed(1)}%`);
|
|
252
|
-
|
|
253
|
-
if (this.failed === 0) {
|
|
254
|
-
console.log('\n๐ ALL TESTS PASSED - READY FOR PUBLICATION!');
|
|
255
|
-
console.log('\n๐ Recommended publication commands:');
|
|
256
|
-
console.log(' npm publish');
|
|
257
|
-
console.log(' git tag v' + packageJson.version);
|
|
258
|
-
console.log(' git push --tags');
|
|
259
|
-
} else {
|
|
260
|
-
console.log('\nโ SOME TESTS FAILED - FIX ISSUES BEFORE PUBLICATION');
|
|
261
|
-
console.log(' Run the comprehensive test suite for detailed analysis:');
|
|
262
|
-
console.log(' node tests/comprehensive-test.js');
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
console.log('='.repeat(60) + '\n');
|
|
266
|
-
|
|
267
|
-
return this.failed === 0;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// Run the quick test
|
|
272
|
-
if (require.main === module) {
|
|
273
|
-
const quickTest = new QuickTest();
|
|
274
|
-
quickTest.run().then(success => {
|
|
275
|
-
process.exit(success ? 0 : 1);
|
|
276
|
-
}).catch(error => {
|
|
277
|
-
console.error('โ Quick test failed:', error);
|
|
278
|
-
process.exit(1);
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
module.exports = QuickTest;
|