@liangshanli/mcp-server-project-standards 3.0.1 → 5.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.
@@ -1,38 +1,38 @@
1
1
  const { getAllowedMethods, loadApiConfig, saveApiConfig, detectContentType } = require('./api_common');
2
2
  const https = require('https');
3
3
 
4
- // HTTPS 请求创建跳过证书验证的 agent
4
+ // Create an agent for HTTPS requests that skips certificate verification
5
5
  const httpsAgent = new https.Agent({
6
6
  rejectUnauthorized: false
7
7
  });
8
8
 
9
9
  /**
10
- * API 调试工具 - 直接执行API请求
10
+ * API Debug Tool - Direct API request execution
11
11
  *
12
- * 支持的请求体格式:
13
- * 1. JSON对象: {"username": "admin", "password": "123456"}
14
- * 2. 表单数据: "username=admin&password=123456"
15
- * 3. 纯文本: "Hello World"
12
+ * Supported body formats:
13
+ * 1. JSON object: {"username": "admin", "password": "123456"}
14
+ * 2. Form data: "username=admin&password=123456"
15
+ * 3. Plain text: "Hello World"
16
16
  * 4. XML: "<user><name>John</name><email>john@example.com</email></user>"
17
17
  * 5. HTML: "<html><body>Content</body></html>"
18
18
  *
19
- * 自动内容类型检测:
20
- * - JSON对象 → application/json
21
- * - 表单数据 → application/x-www-form-urlencoded
19
+ * Auto content-type detection:
20
+ * - JSON object → application/json
21
+ * - Form data → application/x-www-form-urlencoded
22
22
  * - XML → application/xml
23
23
  * - HTML → text/html
24
- * - 纯文本 → text/plain
24
+ * - Plain text → text/plain
25
25
  *
26
- * @param {Object} params - 参数
27
- * @param {string} params.url - 要执行的接口URL(必需)
28
- * @param {string} params.method - HTTP方法(可选,默认GET
29
- * @param {Object} params.headers - 额外请求头(可选)
30
- * @param {Object} params.query - 查询参数(可选)
31
- * @param {*} params.body - 请求体(可选,支持多种格式)
32
- * @param {string} params.contentType - 内容类型(可选,会自动检测)
33
- * @param {Object} config - 服务器配置
34
- * @param {Function} saveConfig - 保存配置函数
35
- * @returns {Object} API调试结果
26
+ * @param {Object} params - Parameters
27
+ * @param {string} params.url - API URL to execute (required)
28
+ * @param {string} params.method - HTTP method (optional, default GET)
29
+ * @param {Object} params.headers - Additional request headers (optional)
30
+ * @param {Object} params.query - Query parameters (optional)
31
+ * @param {*} params.body - Request body (optional, supports multiple formats)
32
+ * @param {string} params.contentType - Content-Type (optional, will be auto-detected)
33
+ * @param {Object} config - Server configuration
34
+ * @param {Function} saveConfig - Save configuration function
35
+ * @returns {Object} API debug result
36
36
  */
37
37
  async function api_debug(params, config, saveConfig) {
38
38
  const { url, method = 'GET', headers = {}, query, body, contentType } = params || {};
@@ -77,10 +77,10 @@ async function api_debug(params, config, saveConfig) {
77
77
  }
78
78
 
79
79
  try {
80
- // 加载当前配置
80
+ // Load current configuration
81
81
  const apiDebugConfig = loadApiConfig();
82
82
 
83
- // 验证请求方法是否被允许
83
+ // Verify if the request method is allowed
84
84
  const allowedMethods = getAllowedMethods();
85
85
  const requestMethod = method.toUpperCase();
86
86
 
@@ -88,7 +88,7 @@ async function api_debug(params, config, saveConfig) {
88
88
  throw new Error(`Method ${requestMethod} is not allowed. Allowed methods: ${allowedMethods.join(', ')}`);
89
89
  }
90
90
 
91
- // 构建完整 URL
91
+ // Build full URL
92
92
  let fullUrl;
93
93
  if (url.startsWith('http://') || url.startsWith('https://')) {
94
94
  fullUrl = url;
@@ -97,23 +97,23 @@ async function api_debug(params, config, saveConfig) {
97
97
  fullUrl = baseUrl + url;
98
98
  }
99
99
 
100
- // 合并请求头
100
+ // Merge request headers
101
101
  const finalHeaders = {
102
102
  ...apiDebugConfig.headers,
103
103
  ...headers
104
104
  };
105
105
 
106
- // 处理请求体
106
+ // Process request body
107
107
  let requestBody = null;
108
108
  if (body && (requestMethod === 'POST' || requestMethod === 'PUT' || requestMethod === 'PATCH')) {
109
109
  if (typeof body === 'string') {
110
- // 检查是否以 { 开头但无法解析为JSON对象
110
+ // Check if it starts with { but cannot be parsed as a JSON object
111
111
  if (body.trim().startsWith('{')) {
112
112
  try {
113
113
  JSON.parse(body);
114
- // 如果能解析成功,继续正常处理
114
+ // If can parse successfully, continue normal processing
115
115
  } catch (parseError) {
116
- // 无法解析为JSON,给出建议
116
+ // Cannot parse as JSON, give suggestions
117
117
  return {
118
118
  contentType: "text",
119
119
  content: [
@@ -146,21 +146,21 @@ async function api_debug(params, config, saveConfig) {
146
146
  }
147
147
  }
148
148
 
149
- // 检查是否指定了 Content-Type
149
+ // Check if Content-Type is specified
150
150
  if (contentType) {
151
151
  finalHeaders['Content-Type'] = contentType;
152
152
  requestBody = body;
153
153
  } else {
154
- // 自动判断 Content-Type
154
+ // Auto-detect Content-Type
155
155
  const detectedType = detectContentType(body);
156
156
  finalHeaders['Content-Type'] = detectedType;
157
157
  requestBody = body;
158
158
  }
159
159
  } else if (typeof body === 'object') {
160
- // 检查是否指定了 Content-Type
160
+ // Check if Content-Type is specified
161
161
  if (contentType) {
162
162
  if (contentType === 'application/x-www-form-urlencoded') {
163
- // 转换为 URL 编码格式
163
+ // Convert to URL encoded format
164
164
  const formData = new URLSearchParams();
165
165
  Object.entries(body).forEach(([key, value]) => {
166
166
  if (value !== null && value !== undefined) {
@@ -170,19 +170,19 @@ async function api_debug(params, config, saveConfig) {
170
170
  finalHeaders['Content-Type'] = 'application/x-www-form-urlencoded';
171
171
  requestBody = formData.toString();
172
172
  } else {
173
- // 其他指定类型,直接序列化
173
+ // Other specified types, serialize directly
174
174
  finalHeaders['Content-Type'] = contentType;
175
175
  requestBody = JSON.stringify(body);
176
176
  }
177
177
  } else {
178
- // 自动判断:对象默认使用 JSON 格式
178
+ // Auto-detect: objects default to JSON format
179
179
  finalHeaders['Content-Type'] = 'application/json';
180
180
  requestBody = JSON.stringify(body);
181
181
  }
182
182
  }
183
183
  }
184
184
 
185
- // 处理查询参数
185
+ // Process query parameters
186
186
  let queryString = '';
187
187
  if (query && Object.keys(query).length > 0) {
188
188
  const queryParams = new URLSearchParams();
@@ -202,21 +202,21 @@ async function api_debug(params, config, saveConfig) {
202
202
  let error = null;
203
203
 
204
204
  try {
205
- // 执行请求
205
+ // Execute request
206
206
  const fetchOptions = {
207
207
  method: requestMethod,
208
208
  headers: finalHeaders,
209
209
  body: requestBody
210
210
  };
211
211
 
212
- // HTTPS 请求添加 agent 以跳过证书验证
212
+ // Add agent to HTTPS requests to skip certificate verification
213
213
  if (finalRequestUrl.startsWith('https')) {
214
214
  fetchOptions.agent = httpsAgent;
215
215
  }
216
216
 
217
217
  response = await fetch(finalRequestUrl, fetchOptions);
218
218
 
219
- // 获取响应数据
219
+ // Get response data
220
220
  const responseContentType = response.headers.get('content-type');
221
221
 
222
222
  if (responseContentType && responseContentType.includes('application/json')) {
@@ -225,7 +225,7 @@ async function api_debug(params, config, saveConfig) {
225
225
  responseData = await response.text();
226
226
  }
227
227
 
228
- // 判断请求是否成功(HTTP 状态码 200-299 为成功)
228
+ // Determine if the request was successful (HTTP status code 200-299)
229
229
  const isHttpSuccess = response.status >= 200 && response.status < 300;
230
230
  success = isHttpSuccess;
231
231
 
@@ -235,20 +235,20 @@ async function api_debug(params, config, saveConfig) {
235
235
  }
236
236
 
237
237
  if (success && response) {
238
- // 自动将接口添加到配置列表中
238
+ // Automatically add interface to the configuration list
239
239
  try {
240
240
  const apiConfig = loadApiConfig();
241
241
  if (!apiConfig.list) {
242
242
  apiConfig.list = [];
243
243
  }
244
244
 
245
- // 检查是否已存在相同的接口
245
+ // Check if the same interface already exists
246
246
  const existingApiIndex = apiConfig.list.findIndex(api =>
247
247
  api.url === url && api.method === requestMethod
248
248
  );
249
249
 
250
250
  if (existingApiIndex === -1) {
251
- // 如果不存在,添加到列表
251
+ // If it doesn't exist, add to the list
252
252
  const newApi = {
253
253
  url: url,
254
254
  method: requestMethod,
@@ -281,7 +281,7 @@ async function api_debug(params, config, saveConfig) {
281
281
  timestamp: new Date().toISOString()
282
282
  };
283
283
  } else {
284
- // 如果已存在,更新接口信息
284
+ // If it already exists, update the interface information
285
285
  apiConfig.list[existingApiIndex] = {
286
286
  ...apiConfig.list[existingApiIndex],
287
287
  url: url,
@@ -313,7 +313,7 @@ async function api_debug(params, config, saveConfig) {
313
313
  };
314
314
  }
315
315
  } catch (saveError) {
316
- // 如果保存失败,仍然返回成功响应
316
+ // If saving fails, still return a success response
317
317
  console.error('Failed to save API to list:', saveError.message);
318
318
  return {
319
319
  success: true,
@@ -334,6 +334,7 @@ async function api_debug(params, config, saveConfig) {
334
334
  };
335
335
  }
336
336
  } else {
337
+ // Return response data even on failure
337
338
  return {
338
339
  success: false,
339
340
  message: `Failed to execute API: ${url}`,
@@ -343,6 +344,12 @@ async function api_debug(params, config, saveConfig) {
343
344
  headers: finalHeaders,
344
345
  body: requestBody
345
346
  },
347
+ response: response ? {
348
+ status: response.status,
349
+ statusText: response.statusText,
350
+ headers: Object.fromEntries(response.headers.entries()),
351
+ data: responseData
352
+ } : undefined,
346
353
  error: error || (response ? `HTTP ${response.status}: ${response.statusText}` : 'Request failed'),
347
354
  timestamp: new Date().toISOString()
348
355
  };
@@ -1,24 +1,25 @@
1
1
  const { loadApiConfig, getAllowedMethods } = require('./api_common');
2
+ const https = require('https');
2
3
 
3
- // 设置全局环境变量以跳过证书验证
4
- if (!process.env.NODE_TLS_REJECT_UNAUTHORIZED) {
5
- process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
6
- }
4
+ // Create an agent for HTTPS requests that skips certificate verification
5
+ const httpsAgent = new https.Agent({
6
+ rejectUnauthorized: false
7
+ });
7
8
 
8
9
  /**
9
- * API 执行工具 - 通过索引执行已配置的API
10
- * @param {Object} params - 参数
11
- * @param {number} params.index - API索引(必需)
12
- * @param {Object} params.overrides - 覆盖参数(可选)
13
- * @param {string} params.overrides.url - 覆盖URL
14
- * @param {string} params.overrides.method - 覆盖HTTP方法
15
- * @param {Object} params.overrides.headers - 覆盖请求头
16
- * @param {Object} params.overrides.query - 覆盖查询参数
17
- * @param {*} params.overrides.body - 覆盖请求体
18
- * @param {string} params.overrides.contentType - 覆盖内容类型
19
- * @param {Object} config - 服务器配置
20
- * @param {Function} saveConfig - 保存配置函数
21
- * @returns {Object} API执行结果
10
+ * API Execute Tool - Execute configured APIs by index
11
+ * @param {Object} params - Parameters
12
+ * @param {number} params.index - API index (required)
13
+ * @param {Object} params.overrides - Override parameters (optional)
14
+ * @param {string} params.overrides.url - Override URL
15
+ * @param {string} params.overrides.method - Override HTTP method
16
+ * @param {Object} params.overrides.headers - Override request headers
17
+ * @param {Object} params.overrides.query - Override query parameters
18
+ * @param {*} params.overrides.body - Override request body
19
+ * @param {string} params.overrides.contentType - Override content type
20
+ * @param {Object} config - Server configuration
21
+ * @param {Function} saveConfig - Save configuration function
22
+ * @returns {Object} API execution result
22
23
  */
23
24
  async function api_execute(params, config, saveConfig) {
24
25
  const { index, overrides = {} } = params || {};
@@ -28,7 +29,7 @@ async function api_execute(params, config, saveConfig) {
28
29
  }
29
30
 
30
31
  try {
31
- // 加载API配置
32
+ // Load API configuration
32
33
  const apiDebugConfig = loadApiConfig();
33
34
 
34
35
  if (!apiDebugConfig.list || !Array.isArray(apiDebugConfig.list)) {
@@ -39,10 +40,10 @@ async function api_execute(params, config, saveConfig) {
39
40
  throw new Error(`API index ${index} is out of range. Available APIs: 0-${apiDebugConfig.list.length - 1}`);
40
41
  }
41
42
 
42
- // 获取API配置
43
+ // Get API configuration
43
44
  const apiConfig = apiDebugConfig.list[index];
44
45
 
45
- // 合并配置和覆盖参数
46
+ // Merge configuration and override parameters
46
47
  const finalConfig = {
47
48
  url: overrides.url || apiConfig.url,
48
49
  method: overrides.method || apiConfig.method || 'GET',
@@ -52,13 +53,13 @@ async function api_execute(params, config, saveConfig) {
52
53
  contentType: overrides.contentType || apiConfig.contentType
53
54
  };
54
55
 
55
- // 验证HTTP方法
56
+ // Verify HTTP method
56
57
  const allowedMethods = getAllowedMethods();
57
58
  if (!allowedMethods.includes(finalConfig.method.toUpperCase())) {
58
59
  throw new Error(`HTTP method '${finalConfig.method}' is not allowed. Allowed methods: ${allowedMethods.join(', ')}`);
59
60
  }
60
61
 
61
- // 构建完整URL
62
+ // Build full URL
62
63
  let fullUrl;
63
64
  if (finalConfig.url.startsWith('http://') || finalConfig.url.startsWith('https://')) {
64
65
  fullUrl = finalConfig.url;
@@ -66,19 +67,19 @@ async function api_execute(params, config, saveConfig) {
66
67
  fullUrl = apiDebugConfig.baseUrl + finalConfig.url;
67
68
  }
68
69
 
69
- // 添加查询参数
70
+ // Add query parameters
70
71
  if (finalConfig.query && Object.keys(finalConfig.query).length > 0) {
71
72
  const queryString = new URLSearchParams(finalConfig.query).toString();
72
73
  fullUrl += (fullUrl.includes('?') ? '&' : '?') + queryString;
73
74
  }
74
75
 
75
- // 准备请求选项
76
+ // Prepare request options
76
77
  const requestOptions = {
77
78
  method: finalConfig.method.toUpperCase(),
78
79
  headers: finalConfig.headers
79
80
  };
80
81
 
81
- // 处理请求体
82
+ // Process request body
82
83
  if (finalConfig.body && ['POST', 'PUT', 'PATCH'].includes(finalConfig.method.toUpperCase())) {
83
84
  if (typeof finalConfig.body === 'object') {
84
85
  requestOptions.body = JSON.stringify(finalConfig.body);
@@ -93,23 +94,41 @@ async function api_execute(params, config, saveConfig) {
93
94
  }
94
95
  }
95
96
 
96
- // 执行请求
97
+ // Execute request
97
98
  const startTime = Date.now();
98
- const response = await fetch(fullUrl, requestOptions);
99
- const endTime = Date.now();
100
-
101
- // 处理响应
99
+ let response;
102
100
  let responseData;
103
- const contentType = response.headers.get('content-type') || '';
101
+ let error = null;
104
102
 
105
- if (contentType.includes('application/json')) {
106
- responseData = await response.json();
107
- } else {
108
- responseData = await response.text();
103
+ try {
104
+ // Add agent to HTTPS requests to skip certificate verification
105
+ if (fullUrl.startsWith('https')) {
106
+ requestOptions.agent = httpsAgent;
107
+ }
108
+
109
+ response = await fetch(fullUrl, requestOptions);
110
+
111
+ // Process response
112
+ const contentType = response.headers.get('content-type') || '';
113
+
114
+ if (contentType.includes('application/json')) {
115
+ responseData = await response.json();
116
+ } else {
117
+ responseData = await response.text();
118
+ }
119
+ } catch (fetchError) {
120
+ error = fetchError.message;
121
+ throw new Error(`Failed to execute API request: ${error}`);
109
122
  }
110
123
 
124
+ const endTime = Date.now();
125
+
126
+ // Determine if the request was successful (HTTP status code 200-299)
127
+ const isHttpSuccess = response.status >= 200 && response.status < 300;
128
+ const success = isHttpSuccess;
129
+
111
130
  return {
112
- success: true,
131
+ success: success,
113
132
  index: index,
114
133
  api: {
115
134
  url: apiConfig.url,
@@ -129,6 +148,7 @@ async function api_execute(params, config, saveConfig) {
129
148
  headers: Object.fromEntries(response.headers.entries()),
130
149
  data: responseData
131
150
  },
151
+ error: success ? undefined : (error || `HTTP ${response.status}: ${response.statusText}`),
132
152
  timing: {
133
153
  duration: endTime - startTime,
134
154
  timestamp: new Date().toISOString()
@@ -1,32 +1,32 @@
1
1
  const { getLoginUrl, getLoginMethod, getLoginBody, loadApiConfig, saveApiConfig } = require('./api_common');
2
2
  const https = require('https');
3
3
 
4
- // HTTPS 请求创建跳过证书验证的 agent
4
+ // Create an agent for HTTPS requests that skips certificate verification
5
5
  const httpsAgent = new https.Agent({
6
6
  rejectUnauthorized: false
7
7
  });
8
8
 
9
9
  /**
10
- * API 登录工具 - 直接执行登录请求(从环境变量获取登录信息)
11
- * @param {Object} params - 参数
12
- * @param {string} params.baseUrl - 基础URL(可选,会覆盖配置中的baseUrl
13
- * @param {Object} config - 服务器配置
14
- * @param {Function} saveConfig - 保存配置函数
15
- * @returns {Object} 登录结果
10
+ * API Login Tool - Execute login request directly (Get login info from environment variables)
11
+ * @param {Object} params - Parameters
12
+ * @param {string} params.baseUrl - Base URL (optional, overrides baseUrl in configuration)
13
+ * @param {Object} config - Server configuration
14
+ * @param {Function} saveConfig - Save configuration function
15
+ * @returns {Object} Login result
16
16
  */
17
17
  async function api_login(params, config, saveConfig) {
18
18
  const { baseUrl } = params || {};
19
19
 
20
20
  try {
21
- // 加载当前配置
21
+ // Load current configuration
22
22
  const apiDebugConfig = loadApiConfig();
23
23
 
24
- // 使用传入的baseUrl或配置中的baseUrl
24
+ // Use passed baseUrl or baseUrl from configuration
25
25
  const finalBaseUrl = baseUrl || apiDebugConfig.baseUrl || '';
26
26
  const loginUrl = getLoginUrl();
27
27
  const loginMethod = getLoginMethod();
28
28
 
29
- // 构建完整登录URL
29
+ // Build full login URL
30
30
  let fullLoginUrl;
31
31
  if (loginUrl.startsWith('http://') || loginUrl.startsWith('https://')) {
32
32
  fullLoginUrl = loginUrl;
@@ -34,29 +34,29 @@ async function api_login(params, config, saveConfig) {
34
34
  fullLoginUrl = finalBaseUrl + loginUrl;
35
35
  }
36
36
 
37
- // 从环境变量获取登录请求体
37
+ // Get login request body from environment variables
38
38
  const loginBodyRaw = getLoginBody();
39
39
  let loginBody;
40
40
 
41
- // 处理不同格式的请求体
41
+ // Process request body in different formats
42
42
  if (typeof loginBodyRaw === 'string') {
43
- // 如果是字符串,直接使用
43
+ // If it's a string, use it directly
44
44
  loginBody = loginBodyRaw;
45
45
  } else if (typeof loginBodyRaw === 'object') {
46
- // 如果是对象,转换为JSON字符串
46
+ // If it's an object, convert to JSON string
47
47
  loginBody = JSON.stringify(loginBodyRaw);
48
48
  } else {
49
- // 其他情况,使用默认格式
49
+ // Otherwise, use default format
50
50
  loginBody = '{"username":"","password":""}';
51
51
  }
52
52
 
53
- // 准备请求头
53
+ // Prepare request headers
54
54
  const headers = {
55
55
  ...apiDebugConfig.headers,
56
56
  'Content-Type': 'application/json'
57
57
  };
58
58
 
59
- // 执行登录请求
59
+ // Execute login request
60
60
  let response;
61
61
  let responseData;
62
62
  let success = true;
@@ -69,14 +69,14 @@ async function api_login(params, config, saveConfig) {
69
69
  body: loginBody
70
70
  };
71
71
 
72
- // HTTPS 请求添加 agent 以跳过证书验证
72
+ // Add agent to HTTPS requests to skip certificate verification
73
73
  if (fullLoginUrl.startsWith('https')) {
74
74
  fetchOptions.agent = httpsAgent;
75
75
  }
76
76
 
77
77
  response = await fetch(fullLoginUrl, fetchOptions);
78
78
 
79
- // 获取响应数据
79
+ // Get response data
80
80
  const contentType = response.headers.get('content-type');
81
81
 
82
82
  if (contentType && contentType.includes('application/json')) {
@@ -85,17 +85,17 @@ async function api_login(params, config, saveConfig) {
85
85
  responseData = await response.text();
86
86
  }
87
87
 
88
- // 判断登录是否成功
88
+ // Determine if login was successful
89
89
  const isHttpSuccess = response.status >= 200 && response.status < 300;
90
90
  success = isHttpSuccess;
91
91
 
92
92
  if (success) {
93
- // 登录成功,尝试提取token并更新公共请求头
93
+ // Login successful, try to extract token and update common headers
94
94
  let token = null;
95
95
 
96
- // 尝试从响应中提取token
96
+ // Try to extract token from response
97
97
  if (responseData && typeof responseData === 'object') {
98
- // 常见的token字段名
98
+ // Common token field names
99
99
  const tokenFields = ['token', 'access_token', 'accessToken', 'authToken', 'jwt'];
100
100
  for (const field of tokenFields) {
101
101
  if (responseData[field]) {
@@ -105,7 +105,7 @@ async function api_login(params, config, saveConfig) {
105
105
  }
106
106
  }
107
107
 
108
- // 如果找到token,自动更新Authorization
108
+ // If token is found, automatically update Authorization header
109
109
  if (token) {
110
110
  apiDebugConfig.headers = {
111
111
  ...apiDebugConfig.headers,
@@ -21,7 +21,7 @@ async function database_standards(params, config, saveConfig) {
21
21
 
22
22
  if (action === 'get') {
23
23
  try {
24
- // 从配置文件的 database_standards 字段中获取标准,如果没有则使用默认值
24
+ // Get standards from database_standards field in config file, use default if not present
25
25
  const databaseStandards = config?.database_standards || [
26
26
  'Use meaningful table names with descriptive prefixes',
27
27
  'Use snake_case for table and column names',
@@ -69,23 +69,23 @@ async function database_standards(params, config, saveConfig) {
69
69
  }
70
70
 
71
71
  try {
72
- // 更新配置
72
+ // Update configuration
73
73
  if (!config.database_standards) {
74
74
  config.database_standards = [];
75
75
  }
76
76
 
77
- // 处理数组类型的合并逻辑
77
+ // Handle merging logic for array types
78
78
  if (!forceOverwrite) {
79
- // 如果 forceOverwrite false,则合并数组而不是覆盖
79
+ // Merge array instead of overwrite if forceOverwrite is false
80
80
  const existingArray = config.database_standards;
81
81
  const newArray = [...new Set([...existingArray, ...standards])];
82
82
  config.database_standards = newArray;
83
83
  } else {
84
- // 直接覆盖
84
+ // Overwrite directly
85
85
  config.database_standards = standards;
86
86
  }
87
87
 
88
- // 保存配置
88
+ // Save configuration
89
89
  const saved = saveConfig(config);
90
90
  if (!saved) {
91
91
  throw new Error('Failed to save configuration');
@@ -111,17 +111,17 @@ async function database_standards(params, config, saveConfig) {
111
111
  }
112
112
 
113
113
  try {
114
- // 确保 config.database_standards 存在
114
+ // Ensure config.database_standards exists
115
115
  if (!config.database_standards) {
116
116
  config.database_standards = [];
117
117
  }
118
118
 
119
- // 查找并删除指定的 standard
119
+ // Find and delete specified standard
120
120
  const standardIndex = config.database_standards.indexOf(standard);
121
121
  if (standardIndex !== -1) {
122
122
  config.database_standards.splice(standardIndex, 1);
123
123
 
124
- // 保存配置
124
+ // Save configuration
125
125
  const saved = saveConfig(config);
126
126
  if (!saved) {
127
127
  throw new Error('Failed to save configuration');