mcp-osp-prompt 1.0.0
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 +358 -0
- package/config.js +340 -0
- package/dialog/browser.js +532 -0
- package/dialog/constants.js +68 -0
- package/dialog/http-server.js +95 -0
- package/dialog/index.js +106 -0
- package/dialog/native.js +345 -0
- package/dialog/objc.js +303 -0
- package/dialog/utils.js +140 -0
- package/fetcher.js +56 -0
- package/package.json +49 -0
- package/platform-utils.js +206 -0
- package/prompt-manager.js +1027 -0
- package/resource-manager.js +358 -0
- package/server.js +305 -0
- package/test.js +93 -0
- package/tools.js +701 -0
- package/utils.js +145 -0
package/test.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
|
|
3
|
+
function rpc(id, method, params) {
|
|
4
|
+
return JSON.stringify({ jsonrpc: '2.0', id, method, params }) + '\n';
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
console.log('๐งช Starting comprehensive MCP server tests...');
|
|
8
|
+
|
|
9
|
+
(async () => {
|
|
10
|
+
// Set automated mode to skip GUI dialogs and required environment variables
|
|
11
|
+
process.env.AUTOMATED_MODE = 'true';
|
|
12
|
+
process.env.RESOURCE_PATH = '../dev-arch'; // Use local test path (parent directory)
|
|
13
|
+
process.env.GIT_TOKEN = 'test-token'; // Dummy token for testing
|
|
14
|
+
|
|
15
|
+
const proc = spawn('node', ['server.js'], {
|
|
16
|
+
cwd: process.cwd(),
|
|
17
|
+
stdio: ['pipe', 'pipe', 'inherit'],
|
|
18
|
+
env: {
|
|
19
|
+
...process.env,
|
|
20
|
+
AUTOMATED_MODE: 'true',
|
|
21
|
+
RESOURCE_PATH: '../dev-arch',
|
|
22
|
+
GIT_TOKEN: 'test-token'
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const responses = {};
|
|
27
|
+
let testId = 1;
|
|
28
|
+
|
|
29
|
+
proc.stdout.on('data', chunk => {
|
|
30
|
+
chunk.toString().split('\n').filter(Boolean).forEach(line => {
|
|
31
|
+
try {
|
|
32
|
+
const res = JSON.parse(line);
|
|
33
|
+
responses[res.id] = res;
|
|
34
|
+
} catch (e) {
|
|
35
|
+
console.log('Non-JSON output:', line);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Test 1: Initialize
|
|
41
|
+
console.log('Test 1: Initialize...');
|
|
42
|
+
proc.stdin.write(rpc(testId++, 'initialize', {}));
|
|
43
|
+
|
|
44
|
+
// Test 2: List tools
|
|
45
|
+
console.log('Test 2: List tools...');
|
|
46
|
+
proc.stdin.write(rpc(testId++, 'tools/list', {}));
|
|
47
|
+
|
|
48
|
+
// Test 3: Call dev-feature tool
|
|
49
|
+
console.log('Test 3: Call dev-feature tool...');
|
|
50
|
+
proc.stdin.write(rpc(testId++, 'tools/call', { name: 'dev-feature', arguments: { source: 'automated test' } }));
|
|
51
|
+
|
|
52
|
+
// Test 4: Call dev-feedback tool
|
|
53
|
+
console.log('Test 4: Call dev-feedback tool...');
|
|
54
|
+
proc.stdin.write(rpc(testId++, 'tools/call', { name: 'dev-feedback', arguments: { title: 'Test', message: 'Continue?', options: ['Yes', 'No'] } }));
|
|
55
|
+
|
|
56
|
+
// Test 5: Call dev-manual tool (will use automated defaults)
|
|
57
|
+
console.log('Test 5: Call dev-manual tool...');
|
|
58
|
+
proc.stdin.write(rpc(testId++, 'tools/call', { name: 'dev-manual', arguments: {} }));
|
|
59
|
+
|
|
60
|
+
// Wait for responses
|
|
61
|
+
await new Promise(r => setTimeout(r, 3000));
|
|
62
|
+
|
|
63
|
+
// Validate responses
|
|
64
|
+
const tests = [
|
|
65
|
+
{ id: 1, name: 'initialize', check: r => r?.result?.protocolVersion },
|
|
66
|
+
{ id: 2, name: 'tools/list', check: r => r?.result?.tools?.length >= 5 },
|
|
67
|
+
{ id: 3, name: 'dev-feature tool', check: r => r?.result?.content?.[0]?.text },
|
|
68
|
+
{ id: 4, name: 'dev-feedback tool', check: r => r?.result?.content?.[0]?.text },
|
|
69
|
+
{ id: 5, name: 'dev-manual tool', check: r => r?.result?.content?.[0]?.text }
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
let passed = 0;
|
|
73
|
+
for (const test of tests) {
|
|
74
|
+
const response = responses[test.id];
|
|
75
|
+
if (test.check(response)) {
|
|
76
|
+
console.log(`โ
${test.name} - PASSED`);
|
|
77
|
+
passed++;
|
|
78
|
+
} else {
|
|
79
|
+
console.log(`โ ${test.name} - FAILED`);
|
|
80
|
+
console.log('Response:', JSON.stringify(response, null, 2));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
console.log(`\n๐ฏ Results: ${passed}/${tests.length} tests passed`);
|
|
85
|
+
|
|
86
|
+
if (passed === tests.length) {
|
|
87
|
+
console.log('๐ All tests passed!');
|
|
88
|
+
} else {
|
|
89
|
+
console.log('โ ๏ธ Some tests failed');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
proc.kill();
|
|
93
|
+
})().catch(console.error);
|