worsoft-frontend-codegen-local-mcp 0.1.35 → 0.1.37
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 +13 -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.37';
|
|
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');
|
|
@@ -309,11 +309,6 @@ const TOOL_SCHEMA = {
|
|
|
309
309
|
type: 'string',
|
|
310
310
|
description: 'Explicit zh-cn i18n namespace, for example admin.iwmSysTrade. When provided, MCP writes zh-cn content to the matching file path and namespace instead of deriving them from moduleName and functionName.',
|
|
311
311
|
},
|
|
312
|
-
generationMode: {
|
|
313
|
-
type: 'string',
|
|
314
|
-
enum: ['create_new', 'overwrite_existing', 'patch_existing'],
|
|
315
|
-
description: 'Structured generation mode from parseResult. MCP currently uses this as a pass-through runtime hint and result annotation.',
|
|
316
|
-
},
|
|
317
312
|
writeToDisk: { type: 'boolean', default: true, description: 'Whether to write generated files.' },
|
|
318
313
|
overwrite: { type: 'boolean', default: true, description: 'Whether to overwrite existing files. If false, existing files are skipped.' },
|
|
319
314
|
writeSupportFiles: {
|
|
@@ -434,6 +429,16 @@ function resolveGenerationTargets({ moduleName, functionName, apiPath, targetVie
|
|
|
434
429
|
};
|
|
435
430
|
}
|
|
436
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
|
+
|
|
437
442
|
function buildViewRoot(model) {
|
|
438
443
|
return path.join(model.frontendPath, 'src', 'views', ...model.targetViewDir.split('/').filter(Boolean));
|
|
439
444
|
}
|
|
@@ -1401,8 +1406,7 @@ function buildMultiLevelDictModel(safeArgs) {
|
|
|
1401
1406
|
targetViewDir: resolvedTargets.targetViewDir,
|
|
1402
1407
|
targetApiModule: resolvedTargets.targetApiModule,
|
|
1403
1408
|
targetI18nKey: resolvedTargets.targetI18nKey,
|
|
1404
|
-
|
|
1405
|
-
frontendPath: path.resolve(safeArgs.frontendPath),
|
|
1409
|
+
frontendPath: normalizeFrontendRootPath(safeArgs.frontendPath),
|
|
1406
1410
|
style: safeArgs.style,
|
|
1407
1411
|
levels: builtLevels,
|
|
1408
1412
|
modules: allModules,
|
|
@@ -1496,7 +1500,6 @@ function buildModel(safeArgs) {
|
|
|
1496
1500
|
targetViewDir: resolvedTargets.targetViewDir,
|
|
1497
1501
|
targetApiModule: resolvedTargets.targetApiModule,
|
|
1498
1502
|
targetI18nKey: resolvedTargets.targetI18nKey,
|
|
1499
|
-
generationMode: safeArgs.generationMode,
|
|
1500
1503
|
pk: pkField,
|
|
1501
1504
|
fields,
|
|
1502
1505
|
optionFields,
|
|
@@ -1504,7 +1507,7 @@ function buildModel(safeArgs) {
|
|
|
1504
1507
|
listFields,
|
|
1505
1508
|
gridFields,
|
|
1506
1509
|
dictTypes,
|
|
1507
|
-
frontendPath:
|
|
1510
|
+
frontendPath: normalizeFrontendRootPath(safeArgs.frontendPath),
|
|
1508
1511
|
style: safeArgs.style,
|
|
1509
1512
|
children,
|
|
1510
1513
|
};
|
|
@@ -2700,7 +2703,6 @@ function ensureArguments(input) {
|
|
|
2700
2703
|
targetViewDir: input.targetViewDir ? String(input.targetViewDir) : '',
|
|
2701
2704
|
targetApiModule: input.targetApiModule ? String(input.targetApiModule) : '',
|
|
2702
2705
|
targetI18nKey: input.targetI18nKey ? String(input.targetI18nKey) : '',
|
|
2703
|
-
generationMode: input.generationMode ? String(input.generationMode) : 'create_new',
|
|
2704
2706
|
writeToDisk: input.writeToDisk === undefined ? true : Boolean(input.writeToDisk),
|
|
2705
2707
|
overwrite: input.overwrite === undefined ? true : Boolean(input.overwrite),
|
|
2706
2708
|
writeSupportFiles: input.writeSupportFiles === undefined ? true : Boolean(input.writeSupportFiles),
|
|
@@ -2744,7 +2746,6 @@ function buildManifest(model, safeArgs, stylePreset, files, note) {
|
|
|
2744
2746
|
targetViewDir: model.targetViewDir,
|
|
2745
2747
|
targetApiModule: model.targetApiModule,
|
|
2746
2748
|
targetI18nKey: model.targetI18nKey,
|
|
2747
|
-
generationMode: model.generationMode || safeArgs.generationMode,
|
|
2748
2749
|
writeToDisk: safeArgs.writeToDisk,
|
|
2749
2750
|
sideEffects: {
|
|
2750
2751
|
writeSupportFiles: safeArgs.writeSupportFiles,
|
|
@@ -2801,7 +2802,6 @@ function buildManifest(model, safeArgs, stylePreset, files, note) {
|
|
|
2801
2802
|
targetViewDir: model.targetViewDir,
|
|
2802
2803
|
targetApiModule: model.targetApiModule,
|
|
2803
2804
|
targetI18nKey: model.targetI18nKey,
|
|
2804
|
-
generationMode: model.generationMode || safeArgs.generationMode,
|
|
2805
2805
|
writeToDisk: safeArgs.writeToDisk,
|
|
2806
2806
|
sideEffects: {
|
|
2807
2807
|
writeSupportFiles: safeArgs.writeSupportFiles,
|
package/package.json
CHANGED