worsoft-frontend-codegen-local-mcp 0.1.21 → 0.1.22
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/mcp_server.js +33 -10
- package/package.json +1 -1
package/mcp_server.js
CHANGED
|
@@ -5,7 +5,7 @@ const fs = require('fs');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
|
|
7
7
|
const SERVER_NAME = 'worsoft-codegen-local';
|
|
8
|
-
const SERVER_VERSION = '0.1.
|
|
8
|
+
const SERVER_VERSION = '0.1.22';
|
|
9
9
|
const PROTOCOL_VERSION = '2024-11-05';
|
|
10
10
|
const TOOL_NAME = 'worsoft_codegen_local_generate_frontend';
|
|
11
11
|
const TEMPLATE_LIBRARY_ROOT = path.resolve(__dirname, '..', 'template');
|
|
@@ -234,12 +234,33 @@ function toPascalCase(value) {
|
|
|
234
234
|
return camel.charAt(0).toUpperCase() + camel.slice(1);
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
function normalizeModuleName(moduleName) {
|
|
238
|
-
if (!moduleName) {
|
|
239
|
-
return 'admin/test';
|
|
240
|
-
}
|
|
241
|
-
return moduleName.replace(/\\/g, '/').replace(/^\/+|\/+$/g, '');
|
|
242
|
-
}
|
|
237
|
+
function normalizeModuleName(moduleName) {
|
|
238
|
+
if (!moduleName) {
|
|
239
|
+
return 'admin/test';
|
|
240
|
+
}
|
|
241
|
+
return moduleName.replace(/\\/g, '/').replace(/^\/+|\/+$/g, '');
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function normalizeModulePathForFeature(moduleName, functionName, apiPath) {
|
|
245
|
+
const normalized = normalizeModuleName(moduleName);
|
|
246
|
+
const segments = normalized.split('/').filter(Boolean);
|
|
247
|
+
if (segments.length <= 1) {
|
|
248
|
+
return normalized;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const duplicateNames = new Set(
|
|
252
|
+
[functionName, apiPath]
|
|
253
|
+
.filter(Boolean)
|
|
254
|
+
.map((item) => String(item).trim())
|
|
255
|
+
.filter(Boolean)
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
while (segments.length > 1 && duplicateNames.has(segments[segments.length - 1])) {
|
|
259
|
+
segments.pop();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return segments.join('/');
|
|
263
|
+
}
|
|
243
264
|
|
|
244
265
|
function toConstantCase(value) {
|
|
245
266
|
return String(value || '')
|
|
@@ -917,14 +938,16 @@ function buildModel(safeArgs) {
|
|
|
917
938
|
const childDictTypes = children.flatMap((child) => child.visibleFields.map((field) => field.dictType).filter(Boolean));
|
|
918
939
|
const dictTypes = [...new Set([...visibleFields.map((field) => field.dictType).filter(Boolean), ...childDictTypes])];
|
|
919
940
|
|
|
941
|
+
const functionName = toCamelCase(safeArgs.tableName);
|
|
942
|
+
const apiPath = safeArgs.apiPath || functionName;
|
|
920
943
|
return {
|
|
921
944
|
featureTitle: safeArgs.featureTitle || safeArgs.tableComment || safeArgs.tableName,
|
|
922
945
|
tableName: safeArgs.tableName,
|
|
923
946
|
tableComment: safeArgs.tableComment || safeArgs.featureTitle || safeArgs.tableName,
|
|
924
|
-
apiPath
|
|
947
|
+
apiPath,
|
|
925
948
|
className: toPascalCase(safeArgs.tableName),
|
|
926
|
-
functionName
|
|
927
|
-
moduleName:
|
|
949
|
+
functionName,
|
|
950
|
+
moduleName: normalizeModulePathForFeature(safeArgs.moduleName, functionName, apiPath),
|
|
928
951
|
pk: pkField,
|
|
929
952
|
fields,
|
|
930
953
|
visibleFields,
|
package/package.json
CHANGED