worsoft-frontend-codegen-local-mcp 0.1.36 → 0.1.38
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/README.md +3 -0
- package/mcp_server.js +20 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,9 @@ This MCP generates Worsoft frontend files from structured JSON metadata.
|
|
|
28
28
|
- `writeSupportFiles`
|
|
29
29
|
- `mergeI18nZh`
|
|
30
30
|
|
|
31
|
+
`frontendPath` must point to the frontend project root such as `E:/own-worker-platform/trunk/worsoft-ui`.
|
|
32
|
+
If the caller accidentally passes the `src` directory, MCP will normalize it back to the project root before rendering files.
|
|
33
|
+
|
|
31
34
|
## Recommended MCP Arguments
|
|
32
35
|
|
|
33
36
|
Single table:
|
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.38';
|
|
9
9
|
const PROTOCOL_VERSION = '2024-11-05';
|
|
10
10
|
const TOOL_NAME = 'worsoft_codegen_local_generate_frontend';
|
|
11
11
|
const STYLE_CATALOG_PATH = path.join(__dirname, 'assets', 'style-catalog.json');
|
|
@@ -154,8 +154,8 @@ const TOOL_SCHEMA = {
|
|
|
154
154
|
apiPath: { type: 'string', description: 'Backend API base path from pre-parsed structured metadata, for example iwmEmpOutsourcePerson.' },
|
|
155
155
|
pageType: {
|
|
156
156
|
type: 'string',
|
|
157
|
-
enum: ['
|
|
158
|
-
description: 'Structured page type from parseResult. MCP consumes this value but does not derive it.
|
|
157
|
+
enum: ['business', 'dict', 'non_standard'],
|
|
158
|
+
description: 'Structured page type from parseResult. MCP consumes this value but does not derive it. Dict pages are restricted to dialog-based templates.',
|
|
159
159
|
},
|
|
160
160
|
style: { type: 'string', enum: Object.keys(STYLE_CATALOG), description: 'Final style id from parseResult or translated mcpPayload. MCP validates it but does not infer it.' },
|
|
161
161
|
fields: {
|
|
@@ -429,6 +429,16 @@ function resolveGenerationTargets({ moduleName, functionName, apiPath, targetVie
|
|
|
429
429
|
};
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
+
function normalizeFrontendRootPath(frontendPath) {
|
|
433
|
+
const resolvedPath = path.resolve(String(frontendPath || ''));
|
|
434
|
+
const normalizedPath = resolvedPath.replace(/[\\/]+$/, '');
|
|
435
|
+
const baseName = path.basename(normalizedPath).toLowerCase();
|
|
436
|
+
if (baseName === 'src') {
|
|
437
|
+
return path.dirname(normalizedPath);
|
|
438
|
+
}
|
|
439
|
+
return normalizedPath;
|
|
440
|
+
}
|
|
441
|
+
|
|
432
442
|
function buildViewRoot(model) {
|
|
433
443
|
return path.join(model.frontendPath, 'src', 'views', ...model.targetViewDir.split('/').filter(Boolean));
|
|
434
444
|
}
|
|
@@ -1243,11 +1253,8 @@ function getStylePreset(styleId) {
|
|
|
1243
1253
|
function normalizePageTypeInput(pageType) {
|
|
1244
1254
|
if (pageType === undefined || pageType === null || pageType === '') return '';
|
|
1245
1255
|
const normalized = String(pageType).trim();
|
|
1246
|
-
if (
|
|
1247
|
-
|
|
1248
|
-
}
|
|
1249
|
-
if (['feature', 'dictionary', 'non_standard'].includes(normalized)) return normalized;
|
|
1250
|
-
throw new Error('Unsupported pageType: ' + normalized);
|
|
1256
|
+
if (['business', 'dict', 'non_standard'].includes(normalized)) return normalized;
|
|
1257
|
+
throw new Error(`Unsupported pageType: ${normalized}. Allowed values are dict, business, non_standard.`);
|
|
1251
1258
|
}
|
|
1252
1259
|
|
|
1253
1260
|
function rejectSemanticStageInputs(input) {
|
|
@@ -1271,9 +1278,9 @@ function validatePageTypeAndStyle(pageType, style) {
|
|
|
1271
1278
|
if (pageType === 'non_standard') {
|
|
1272
1279
|
throw new Error('non_standard pages are not supported by worsoft_codegen_local_generate_frontend');
|
|
1273
1280
|
}
|
|
1274
|
-
if (pageType !== '
|
|
1281
|
+
if (pageType !== 'dict') return;
|
|
1275
1282
|
if (style === 'single_table_jump' || style === 'master_child_jump') {
|
|
1276
|
-
throw new Error(`
|
|
1283
|
+
throw new Error(`Dict pages must use dialog-based styles. pageType=dict does not support style=${style}`);
|
|
1277
1284
|
}
|
|
1278
1285
|
}
|
|
1279
1286
|
|
|
@@ -1389,14 +1396,14 @@ function buildMultiLevelDictModel(safeArgs) {
|
|
|
1389
1396
|
tableName: safeArgs.tableName,
|
|
1390
1397
|
tableComment: safeArgs.tableComment || parentModule.tableComment,
|
|
1391
1398
|
apiPath: safeArgs.apiPath || parentModule.apiPath,
|
|
1392
|
-
pageType: safeArgs.pageType || '
|
|
1399
|
+
pageType: safeArgs.pageType || 'dict',
|
|
1393
1400
|
className: toPascalCase(safeArgs.tableName || parentModule.tableName),
|
|
1394
1401
|
functionName: resolvedTargets.functionName,
|
|
1395
1402
|
moduleName: resolvedTargets.moduleName,
|
|
1396
1403
|
targetViewDir: resolvedTargets.targetViewDir,
|
|
1397
1404
|
targetApiModule: resolvedTargets.targetApiModule,
|
|
1398
1405
|
targetI18nKey: resolvedTargets.targetI18nKey,
|
|
1399
|
-
frontendPath:
|
|
1406
|
+
frontendPath: normalizeFrontendRootPath(safeArgs.frontendPath),
|
|
1400
1407
|
style: safeArgs.style,
|
|
1401
1408
|
levels: builtLevels,
|
|
1402
1409
|
modules: allModules,
|
|
@@ -1497,7 +1504,7 @@ function buildModel(safeArgs) {
|
|
|
1497
1504
|
listFields,
|
|
1498
1505
|
gridFields,
|
|
1499
1506
|
dictTypes,
|
|
1500
|
-
frontendPath:
|
|
1507
|
+
frontendPath: normalizeFrontendRootPath(safeArgs.frontendPath),
|
|
1501
1508
|
style: safeArgs.style,
|
|
1502
1509
|
children,
|
|
1503
1510
|
};
|
package/package.json
CHANGED