()
| 23 | } |
| 24 | |
| 25 | start() { |
| 26 | return new Promise((resolve, reject) => { |
| 27 | this.proc = spawn(VIBIUM, ['mcp'], { |
| 28 | stdio: ['pipe', 'pipe', 'pipe'], |
| 29 | }); |
| 30 | |
| 31 | this.proc.stdout.on('data', (data) => { |
| 32 | this.buffer += data.toString(); |
| 33 | // Process complete JSON lines |
| 34 | const lines = this.buffer.split('\n'); |
| 35 | this.buffer = lines.pop(); // Keep incomplete line in buffer |
| 36 | for (const line of lines) { |
| 37 | if (line.trim()) { |
| 38 | try { |
| 39 | const response = JSON.parse(line); |
| 40 | if (this.resolvers.length > 0) { |
| 41 | const resolver = this.resolvers.shift(); |
| 42 | resolver(response); |
| 43 | } else { |
| 44 | this.responses.push(response); |
| 45 | } |
| 46 | } catch (e) { |
| 47 | // Ignore parse errors for non-JSON output |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | }); |
| 52 | |
| 53 | this.proc.on('error', reject); |
| 54 | |
| 55 | // Give process a moment to start |
| 56 | setTimeout(resolve, 100); |
| 57 | }); |
| 58 | } |
| 59 | |
| 60 | send(method, params = {}, id = null) { |
| 61 | const msg = { |
no test coverage detected