@mastergo/magic-mcp 0.0.2-alpha.2 → 0.0.3-beta

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 CHANGED
@@ -4,15 +4,13 @@ const { spawn } = require("child_process");
4
4
  const path = require("path");
5
5
  const fs = require("fs");
6
6
 
7
- // 获取参数
7
+ // Get arguments
8
8
  const args = process.argv.slice(2);
9
9
  let token = "";
10
10
  let baseUrl = "http://localhost:3000";
11
- let defaultFramework = "";
12
- let showHelp = false;
13
11
  let debug = false;
14
12
 
15
- // 解析参数
13
+ // Parse arguments
16
14
  for (let i = 0; i < args.length; i++) {
17
15
  if (args[i] === "--token" && i + 1 < args.length) {
18
16
  token = args[i + 1];
@@ -20,99 +18,67 @@ for (let i = 0; i < args.length; i++) {
20
18
  } else if (args[i] === "--url" && i + 1 < args.length) {
21
19
  baseUrl = args[i + 1];
22
20
  i++;
23
- } else if (args[i] === "--framework" && i + 1 < args.length) {
24
- defaultFramework = args[i + 1];
25
- i++;
26
21
  } else if (args[i].startsWith("--token=")) {
27
22
  token = args[i].split("=")[1];
28
23
  } else if (args[i].startsWith("--url=")) {
29
24
  baseUrl = args[i].split("=")[1];
30
- } else if (args[i].startsWith("--framework=")) {
31
- defaultFramework = args[i].split("=")[1];
32
- } else if (args[i] === "--help" || args[i] === "-h") {
33
- showHelp = true;
34
25
  } else if (args[i] === "--debug") {
35
26
  debug = true;
36
27
  }
37
28
  }
38
29
 
39
- // 显示帮助信息
40
- if (showHelp) {
41
- console.log("MasterGo Magic MCP - MasterGo 设计工具与 AI 模型的桥梁");
42
- console.log("");
43
- console.log("用法: npx mastergo-magic-mcp [选项]");
44
- console.log("");
45
- console.log("选项:");
46
- console.log(" --token, --token=VALUE MasterGo API Token (必需)");
47
- console.log(
48
- " --url, --url=VALUE API 服务器 URL (可选,默认为 http://localhost:3000)"
49
- );
50
- console.log(" --framework, --framework=VALUE 默认使用的框架 (可选)");
51
- console.log(" --help, -h 显示帮助信息");
52
- console.log(" --debug 启用调试模式,显示更多日志");
53
- console.log("");
54
- console.log("示例:");
55
- console.log(" npx mastergo-magic-mcp --token=abc123");
56
- console.log(
57
- " npx mastergo-magic-mcp --token=abc123 --url=https://example.com"
58
- );
59
- process.exit(0);
60
- }
61
-
62
- // 检查必要参数
30
+ // Check required arguments
63
31
  if (!token) {
64
- console.error("错误: 缺少 MasterGo API Token");
32
+ console.error("Error: Missing MasterGo API Token");
65
33
  console.error(
66
- "用法: npx mastergo-magic-mcp --token=YOUR_TOKEN [--url=API_URL] [--framework=FRAMEWORK]"
34
+ "Usage: npx mastergo-magic-mcp --token=YOUR_TOKEN [--url=API_URL]"
67
35
  );
68
- console.error("使用 --help 或 -h 查看更多信息");
36
+ console.error("Use --help or -h for more information");
69
37
  process.exit(1);
70
38
  }
71
39
 
72
- // 设置环境变量
40
+ // Set environment variables
73
41
  const env = {
74
42
  ...process.env,
75
43
  MASTERGO_API_TOKEN: token,
76
44
  API_BASE_URL: baseUrl,
77
- DEFAULT_FRAMEWORK: defaultFramework,
78
45
  DEBUG: debug ? "true" : "false",
79
46
  };
80
47
 
81
- // 获取包的路径
48
+ // Get package path
82
49
  const packageDir = path.resolve(__dirname, "../dist");
83
50
  const indexPath = path.join(packageDir, "index.js");
84
51
 
85
- // 检查文件是否存在
52
+ // Check if file exists
86
53
  if (!fs.existsSync(indexPath)) {
87
- console.error("错误: 找不到可执行文件。请确保包已正确安装。");
54
+ console.error("Error: Executable file not found. Please ensure the package is correctly installed.");
88
55
  process.exit(1);
89
56
  }
90
57
 
91
58
  if (debug) {
92
- console.log("调试信息:");
93
- console.log(`包路径: ${indexPath}`);
94
- console.log(`Token: ${token ? "已设置" : "未设置"}`);
59
+ console.log("Debug information:");
60
+ console.log(`Package path: ${indexPath}`);
61
+ console.log(`Token: ${token ? "set" : "not set"}`);
95
62
  console.log(`API URL: ${baseUrl}`);
96
- console.log(`默认框架: ${defaultFramework || "未设置"}`);
97
- console.log(`调试模式: ${debug ? "开启" : "关闭"}`);
63
+ console.log(`Debug mode: ${debug ? "enabled" : "disabled"}`);
98
64
  }
99
65
 
100
66
  try {
101
- // 直接运行编译后的文件
67
+ // Directly run the compiled file
102
68
  if (debug) {
103
- console.log("使用 node 运行编译后的代码...");
69
+ console.log("Using node to run the compiled code...");
104
70
  }
105
71
 
106
- // 直接使用 node 运行文件,并传递环境变量
72
+ // Directly use node to run the file, passing environment variables
107
73
  const child = spawn("node", [indexPath], {
108
74
  env: env,
109
75
  stdio: "inherit",
110
76
  });
111
77
 
112
78
  child.on("error", (error) => {
113
- console.error("启动错误:", error);
79
+ console.error("Startup error:", error);
114
80
  if (debug) {
115
- console.error("详细错误信息:", error.stack);
81
+ console.error("Detailed error information:", error.stack);
116
82
  }
117
83
  process.exit(1);
118
84
  });
@@ -121,9 +87,9 @@ try {
121
87
  process.exit(code || 0);
122
88
  });
123
89
  } catch (error) {
124
- console.error("运行时错误:", error);
90
+ console.error("Runtime error:", error);
125
91
  if (debug) {
126
- console.error("详细错误信息:", error.stack);
92
+ console.error("Detailed error information:", error.stack);
127
93
  }
128
94
  process.exit(1);
129
95
  }