flutter-skill-mcp 0.2.0 → 0.2.5
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/bin/cli.js +22 -28
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const { spawn } = require('child_process');
|
|
3
|
+
const { spawn, execSync } = require('child_process');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
|
|
@@ -11,7 +11,7 @@ const serverScript = path.join(dartDir, 'bin', 'server.dart');
|
|
|
11
11
|
// Check if Dart is installed
|
|
12
12
|
function checkDart() {
|
|
13
13
|
try {
|
|
14
|
-
|
|
14
|
+
execSync('dart --version', { stdio: 'ignore' });
|
|
15
15
|
return true;
|
|
16
16
|
} catch (e) {
|
|
17
17
|
return false;
|
|
@@ -21,7 +21,7 @@ function checkDart() {
|
|
|
21
21
|
// Check if Flutter is installed
|
|
22
22
|
function checkFlutter() {
|
|
23
23
|
try {
|
|
24
|
-
|
|
24
|
+
execSync('flutter --version', { stdio: 'ignore' });
|
|
25
25
|
return true;
|
|
26
26
|
} catch (e) {
|
|
27
27
|
return false;
|
|
@@ -34,40 +34,34 @@ if (!checkDart()) {
|
|
|
34
34
|
process.exit(1);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
if (!checkFlutter()) {
|
|
38
|
-
console.error('Warning: Flutter SDK not found. Some features may not work.');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
37
|
// Check if server script exists
|
|
42
38
|
if (!fs.existsSync(serverScript)) {
|
|
43
39
|
console.error('Error: Server script not found at:', serverScript);
|
|
44
40
|
process.exit(1);
|
|
45
41
|
}
|
|
46
42
|
|
|
47
|
-
// Get dependencies
|
|
43
|
+
// Get dependencies silently (redirect to stderr to not interfere with MCP JSON-RPC)
|
|
48
44
|
const pubCmd = checkFlutter() ? 'flutter' : 'dart';
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
stdio: 'inherit'
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
pubGet.on('close', (code) => {
|
|
55
|
-
if (code !== 0) {
|
|
56
|
-
console.error('Failed to get dependencies');
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Start the MCP server
|
|
61
|
-
const server = spawn('dart', ['run', serverScript], {
|
|
45
|
+
try {
|
|
46
|
+
execSync(`${pubCmd} pub get`, {
|
|
62
47
|
cwd: dartDir,
|
|
63
|
-
stdio: '
|
|
48
|
+
stdio: ['ignore', 'pipe', 'pipe'] // Silent - don't interfere with MCP stdin/stdout
|
|
64
49
|
});
|
|
50
|
+
} catch (e) {
|
|
51
|
+
// Log to stderr if pub get fails
|
|
52
|
+
console.error('Warning: pub get failed, dependencies may be missing');
|
|
53
|
+
}
|
|
65
54
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
55
|
+
// Start the MCP server with proper stdio for JSON-RPC
|
|
56
|
+
const server = spawn('dart', ['run', serverScript], {
|
|
57
|
+
cwd: dartDir,
|
|
58
|
+
stdio: 'inherit' // stdin/stdout/stderr passed through for MCP communication
|
|
59
|
+
});
|
|
69
60
|
|
|
70
|
-
|
|
71
|
-
process.
|
|
72
|
-
process.on('SIGTERM', () => server.kill('SIGTERM'));
|
|
61
|
+
server.on('close', (code) => {
|
|
62
|
+
process.exit(code || 0);
|
|
73
63
|
});
|
|
64
|
+
|
|
65
|
+
// Forward signals
|
|
66
|
+
process.on('SIGINT', () => server.kill('SIGINT'));
|
|
67
|
+
process.on('SIGTERM', () => server.kill('SIGTERM'));
|