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/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);