worsoft-frontend-codegen-local-mcp 0.1.60 → 0.1.64

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,3 +1,4 @@
1
+ <!-- 功能名称:{{FEATURE_TITLE}} -->
1
2
  <template>
2
3
  <div class="layout-padding">
3
4
  <div class="layout-padding-auto layout-padding-view flex h-full flex-col">
@@ -1,3 +1,4 @@
1
+ <!-- 功能名称:{{FEATURE_TITLE}} -->
1
2
  <template>
2
3
  <div class="layout-padding">
3
4
  <div class="layout-padding-auto layout-padding-view flex h-full flex-col">
@@ -1,3 +1,4 @@
1
+ <!-- 功能名称:{{FEATURE_TITLE}} -->
1
2
  <template>
2
3
  <div class="layout-padding">
3
4
  <div class="layout-padding-auto layout-padding-view flex h-full flex-col">
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.60';
8
+ const SERVER_VERSION = '0.1.64';
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');
@@ -178,6 +178,7 @@ const TOOL_SCHEMA = {
178
178
  show: { type: ['boolean', 'string'], description: 'Whether the field is shown on the page.' },
179
179
  listShow: { type: ['boolean', 'string'], description: 'Whether the field is shown on the list page.' },
180
180
  formShow: { type: ['boolean', 'string'], description: 'Whether the field is shown on the form page.' },
181
+ formOrder: { type: ['number', 'string'], description: 'Generation-only form field order from PRD detail/form table. This is not emitted to options.ts.' },
181
182
  smart: { type: ['boolean', 'string'], description: 'Whether the field participates in smart keyword search. This must come from PRD, not inferred from type.' },
182
183
  queryType: { type: ['string', 'number'], description: 'Structured query type for list filtering, for example 20 for date ranges or 30 for dictionary filters.' },
183
184
  dictType: { type: 'string', description: 'Dictionary type code from structured metadata.' },
@@ -220,6 +221,7 @@ const TOOL_SCHEMA = {
220
221
  show: { type: ['boolean', 'string'], description: 'Whether the field is shown on the page.' },
221
222
  listShow: { type: ['boolean', 'string'], description: 'Whether the field is shown on the list page.' },
222
223
  formShow: { type: ['boolean', 'string'], description: 'Whether the field is shown on the form page.' },
224
+ formOrder: { type: ['number', 'string'], description: 'Generation-only form field order from PRD detail/form table. This is not emitted to options.ts.' },
223
225
  smart: { type: ['boolean', 'string'], description: 'Whether the field participates in smart keyword search. This must come from PRD, not inferred from type.' },
224
226
  queryType: { type: ['string', 'number'], description: 'Structured query type for list filtering, for example 20 for date ranges or 30 for dictionary filters.' },
225
227
  dictType: { type: 'string', description: 'Dictionary type code from structured metadata.' },
@@ -278,6 +280,7 @@ const TOOL_SCHEMA = {
278
280
  show: { type: ['boolean', 'string'], description: 'Whether the field is shown on the page.' },
279
281
  listShow: { type: ['boolean', 'string'], description: 'Whether the field is shown on the list page.' },
280
282
  formShow: { type: ['boolean', 'string'], description: 'Whether the field is shown on the form page.' },
283
+ formOrder: { type: ['number', 'string'], description: 'Generation-only form field order from PRD detail/form table. This is not emitted to options.ts.' },
281
284
  smart: { type: ['boolean', 'string'], description: 'Whether the field participates in smart keyword search. This must come from PRD, not inferred from type.' },
282
285
  queryType: { type: ['string', 'number'], description: 'Structured query type for list filtering, for example 20 for date ranges or 30 for dictionary filters.' },
283
286
  dictType: { type: 'string', description: 'Dictionary type code from structured metadata.' },
@@ -980,7 +983,7 @@ function normalizeStructuredFormType(value) {
980
983
  if (!normalized) return '';
981
984
  if (normalized === 'date') return 'date';
982
985
  if (normalized === 'datetime') return 'datetime';
983
- if (normalized === 'microme-operator') return 'number';
986
+ if (normalized === 'microme-operator') return 'microme-operator';
984
987
  if (normalized === 'upload') {
985
988
  return 'upload';
986
989
  }
@@ -1139,16 +1142,50 @@ function normalizeStructuredSqlType(value) {
1139
1142
  if (['LOCALDATETIME', 'DATETIME', 'TIMESTAMP'].includes(upper) || ['\u65e5\u671f\u65f6\u95f4', '\u65f6\u95f4\u6233'].includes(normalized)) return 'DATETIME';
1140
1143
  return upper;
1141
1144
  }
1142
- function normalizeStructuredLengthAndScale(lengthValue, scaleValue) {
1143
- const parsed = splitLength(lengthValue);
1144
- const normalizedScale = scaleValue === undefined || scaleValue === null || scaleValue === '' ? parsed.scale : String(scaleValue).trim();
1145
- return {
1146
- length: parsed.length,
1147
- scale: normalizedScale || '',
1148
- };
1149
- }
1150
-
1151
- function normalizeStructuredField(inputField, index, contextLabel) {
1145
+ function normalizeStructuredLengthAndScale(lengthValue, scaleValue) {
1146
+ const parsed = splitLength(lengthValue);
1147
+ const normalizedScale = scaleValue === undefined || scaleValue === null || scaleValue === '' ? parsed.scale : String(scaleValue).trim();
1148
+ return {
1149
+ length: parsed.length,
1150
+ scale: normalizedScale || '',
1151
+ };
1152
+ }
1153
+
1154
+ function parseOptionalOrder(value, label) {
1155
+ if (value === undefined || value === null || value === '') return undefined;
1156
+ const order = Number.parseInt(String(value), 10);
1157
+ if (Number.isNaN(order) || order < 0) {
1158
+ throw new Error(`${label} must be a non-negative integer when provided`);
1159
+ }
1160
+ return order;
1161
+ }
1162
+
1163
+ function sortFieldsForForm(fields) {
1164
+ const seenOrders = new Map();
1165
+ fields.forEach((field) => {
1166
+ if (field.formOrder === undefined) return;
1167
+ const existing = seenOrders.get(field.formOrder);
1168
+ if (existing) {
1169
+ throw new Error(`Duplicate formOrder ${field.formOrder} on fields ${existing} and ${field.fieldName}`);
1170
+ }
1171
+ seenOrders.set(field.formOrder, field.fieldName);
1172
+ });
1173
+ return fields
1174
+ .map((field, index) => ({ field, index }))
1175
+ .sort((left, right) => {
1176
+ const leftOrder = left.field.formOrder;
1177
+ const rightOrder = right.field.formOrder;
1178
+ if (leftOrder !== undefined && rightOrder !== undefined && leftOrder !== rightOrder) {
1179
+ return leftOrder - rightOrder;
1180
+ }
1181
+ if (leftOrder !== undefined && rightOrder === undefined) return -1;
1182
+ if (leftOrder === undefined && rightOrder !== undefined) return 1;
1183
+ return left.index - right.index;
1184
+ })
1185
+ .map((item) => item.field);
1186
+ }
1187
+
1188
+ function normalizeStructuredField(inputField, index, contextLabel) {
1152
1189
  if (!inputField || typeof inputField !== 'object') {
1153
1190
  throw new Error(contextLabel + '[' + index + '] must be an object');
1154
1191
  }
@@ -1177,6 +1214,7 @@ function normalizeStructuredField(inputField, index, contextLabel) {
1177
1214
  const show = parseBooleanLike(inputField.show, true);
1178
1215
  const listShow = parseBooleanLike(inputField.listShow, show);
1179
1216
  const formShow = parseBooleanLike(inputField.formShow, show);
1217
+ const formOrder = parseOptionalOrder(inputField.formOrder, contextLabel + '[' + index + '].formOrder');
1180
1218
 
1181
1219
  return {
1182
1220
  fieldName,
@@ -1195,6 +1233,7 @@ function normalizeStructuredField(inputField, index, contextLabel) {
1195
1233
  show,
1196
1234
  listShow,
1197
1235
  formShow,
1236
+ formOrder,
1198
1237
  smart: parseBooleanLike(inputField.smart, false),
1199
1238
  queryType: Number.isNaN(explicitQueryType)
1200
1239
  ? undefined
@@ -1402,16 +1441,22 @@ function rejectSemanticStageInputs(input) {
1402
1441
  }
1403
1442
  }
1404
1443
 
1405
- function validatePageTypeAndStyle(pageType, style) {
1406
- if (!pageType) return;
1407
- if (pageType === 'non_standard') {
1408
- throw new Error('non_standard pages are not supported by worsoft_codegen_local_generate_frontend');
1409
- }
1410
- if (pageType !== 'dict') return;
1411
- if (style === 'single_table_jump' || style === 'master_child_jump') {
1412
- throw new Error(`Dict pages must use dialog-based styles. pageType=dict does not support style=${style}`);
1413
- }
1414
- }
1444
+ function validatePageTypeAndStyle(pageType, style) {
1445
+ if (!pageType) return;
1446
+ if (pageType === 'non_standard') {
1447
+ throw new Error('non_standard pages are not supported by worsoft_codegen_local_generate_frontend');
1448
+ }
1449
+ if (pageType === 'business') {
1450
+ if (style === 'single_table_dialog') {
1451
+ throw new Error('Business pages must use jump-based styles. pageType=business does not support style=single_table_dialog; use single_table_jump for single-table business pages or master_child_jump for master-child business pages.');
1452
+ }
1453
+ return;
1454
+ }
1455
+ if (pageType !== 'dict') return;
1456
+ if (style === 'single_table_jump' || style === 'master_child_jump') {
1457
+ throw new Error(`Dict pages must use dialog-based styles. pageType=dict does not support style=${style}`);
1458
+ }
1459
+ }
1415
1460
 
1416
1461
  function hasRuntimeSupport(stylePreset) {
1417
1462
  return Boolean(stylePreset.runtime && stylePreset.runtime.supported && stylePreset.runtime.templateDir);
@@ -1519,7 +1564,7 @@ function buildMultiLevelModule(moduleInput, levelIndex) {
1519
1564
  ? ensureFieldExists(fields, moduleInput.primaryKey, moduleInput.tableName, 'Primary key')
1520
1565
  : findPrimaryKeyFromStructuredFields(fields);
1521
1566
  const optionFields = fields.filter((field) => field.fieldName !== normalizedPk.fieldName && !field.isAudit);
1522
- const visibleFields = optionFields.filter((field) => field.formShow !== false);
1567
+ const visibleFields = sortFieldsForForm(optionFields.filter((field) => field.formShow !== false));
1523
1568
  const listFields = optionFields.filter((field) => field.listShow !== false);
1524
1569
  const statusField = detectStatusField(fields, moduleInput.statusField);
1525
1570
  const apiPath = moduleInput.apiPath || toCamelCase(moduleInput.tableName);
@@ -1642,7 +1687,7 @@ function buildChildModels(safeArgs, mainFields, mainPk) {
1642
1687
  const childOptionFields = childFields.filter(
1643
1688
  (field) => field.fieldName !== childPk.fieldName && !field.isAudit && field.fieldName !== relation.childField
1644
1689
  );
1645
- const childVisibleFields = childOptionFields.filter((field) => field.formShow !== false);
1690
+ const childVisibleFields = sortFieldsForForm(childOptionFields.filter((field) => field.formShow !== false));
1646
1691
  const payloadField = relation.payloadField;
1647
1692
  const listName = payloadField;
1648
1693
 
@@ -1675,7 +1720,7 @@ function buildModel(safeArgs) {
1675
1720
  fields: safeArgs.fields,
1676
1721
  });
1677
1722
  const optionFields = fields.filter((field) => field.fieldName !== pkField.fieldName && !field.isAudit);
1678
- const visibleFields = optionFields.filter((field) => field.formShow !== false);
1723
+ const visibleFields = sortFieldsForForm(optionFields.filter((field) => field.formShow !== false));
1679
1724
  const listFields = optionFields.filter((field) => field.listShow !== false);
1680
1725
  const gridFields = listFields.slice(0, 8);
1681
1726
  const statusField = detectStatusField(fields, safeArgs.statusField);
@@ -1747,19 +1792,29 @@ function renderFormField(field) {
1747
1792
  ].join('\n');
1748
1793
  }
1749
1794
 
1750
- if (field.formType === 'number') {
1751
- const max = field.comment.includes('%') || /\u6BD4\u4F8B/.test(field.comment) ? ' :max="100"' : '';
1752
- const precision = field.sqlType === 'DECIMAL' && field.scale ? ` :precision="${field.scale}" :step="0.01"` : '';
1753
- return [
1754
- ' <el-col :span="12" class="mb20">',
1795
+ if (field.formType === 'number') {
1796
+ const max = field.comment.includes('%') || /\u6BD4\u4F8B/.test(field.comment) ? ' :max="100"' : '';
1797
+ const precision = field.sqlType === 'DECIMAL' && field.scale ? ` :precision="${field.scale}" :step="0.01"` : '';
1798
+ return [
1799
+ ' <el-col :span="12" class="mb20">',
1755
1800
  ` <el-form-item label="${label}" prop="${prop}">`,
1756
1801
  ` <el-input-number v-model="form.${prop}" :min="0"${max}${precision} :placeholder="${inputPlaceholderExpr}" style="width: 100%" />`,
1757
1802
  ' </el-form-item>',
1758
1803
  ' </el-col>',
1759
- ].join('\n');
1760
- }
1761
-
1762
- if (field.formType === 'datetime' || field.formType === 'date') {
1804
+ ].join('\n');
1805
+ }
1806
+
1807
+ if (field.formType === 'microme-operator') {
1808
+ return [
1809
+ ' <el-col :span="12" class="mb20">',
1810
+ ` <el-form-item label="${label}" prop="${prop}">`,
1811
+ ` <MicromeOperator v-model="form.${prop}"${renderMicromeFormatAttr(field)} :placeholder="${inputPlaceholderExpr}" />`,
1812
+ ' </el-form-item>',
1813
+ ' </el-col>',
1814
+ ].join('\n');
1815
+ }
1816
+
1817
+ if (field.formType === 'datetime' || field.formType === 'date') {
1763
1818
  const pickerType = field.formType === 'datetime' ? 'datetime' : 'date';
1764
1819
  const formatName = field.formType === 'datetime' ? 'dateTimeStr' : 'dateStr';
1765
1820
  return [
@@ -1824,6 +1879,8 @@ function renderChildTableColumn(field, childListName) {
1824
1879
  const max = field.comment.includes('%') || /\u6BD4\u4F8B/.test(field.comment) ? ' :max="100"' : '';
1825
1880
  const precision = field.sqlType === 'DECIMAL' && field.scale ? ` :precision="${field.scale}" :step="0.01"` : '';
1826
1881
  control = ` <el-input-number v-model="row.${field.attrName}" :min="0"${max}${precision} :placeholder="${inputPlaceholderExpr}" style="width: 100%"${disabledAttr} />`;
1882
+ } else if (field.formType === 'microme-operator') {
1883
+ control = ` <MicromeOperator v-model="row.${field.attrName}"${renderMicromeFormatAttr(field)} :placeholder="${inputPlaceholderExpr}"${disabledAttr} />`;
1827
1884
  }
1828
1885
 
1829
1886
  return [
@@ -1853,7 +1910,7 @@ function renderDefaultLine(field) {
1853
1910
  if (field.attrName === 'billDate') return ` ${field.attrName}: moment(new Date()).format('YYYY-MM-DD'),`;
1854
1911
  if (field.attrName === 'billStateId' || field.fieldName === 'bill_state_id') return ` ${field.attrName}: '0',`;
1855
1912
  if (field.attrName === 'createTime') return ` ${field.attrName}: moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),`;
1856
- if (field.formType === 'number') return ` ${field.attrName}: 0,`;
1913
+ if (field.formType === 'number' || field.formType === 'microme-operator') return ` ${field.attrName}: 0,`;
1857
1914
  return ` ${field.attrName}: '',`;
1858
1915
  }
1859
1916
 
@@ -2049,6 +2106,14 @@ function renderDisabledBoolV2(field) {
2049
2106
  return field.readonly ? 'true' : 'false';
2050
2107
  }
2051
2108
 
2109
+ function renderMicromeFormatAttr(field) {
2110
+ const length = Number.parseInt(String(field.length || ''), 10);
2111
+ const scale = Number.parseInt(String(field.scale || ''), 10);
2112
+ if (!length || Number.isNaN(length) || Number.isNaN(scale) || scale < 0) return '';
2113
+ const integerLength = Math.max(length - scale, 1);
2114
+ return ` format="${integerLength}-${scale}"`;
2115
+ }
2116
+
2052
2117
  function isAttachmentLikeField(field) {
2053
2118
  const fieldName = String(field?.fieldName || field?.attrName || '').toLowerCase();
2054
2119
  const comment = String(field?.comment || field?.description || '').toLowerCase();
@@ -2091,20 +2156,42 @@ function renderFormFieldV2(field) {
2091
2156
  ].join('\n');
2092
2157
  }
2093
2158
 
2094
- if (field.formType === 'number') {
2095
- const max = field.comment.includes('%') || /\u6BD4\u4F8B/.test(field.comment) ? ' :max="100"' : '';
2096
- const precision = field.sqlType === 'DECIMAL' && field.scale ? ` :precision="${field.scale}" :step="0.01"` : '';
2097
- return [
2098
- renderFieldCommentV2(field),
2159
+ if (field.formType === 'number') {
2160
+ const max = field.comment.includes('%') || /\u6BD4\u4F8B/.test(field.comment) ? ' :max="100"' : '';
2161
+ const precision = field.sqlType === 'DECIMAL' && field.scale ? ` :precision="${field.scale}" :step="0.01"` : '';
2162
+ return [
2163
+ renderFieldCommentV2(field),
2099
2164
  ` <el-col :span="12" class="mb20">`,
2100
2165
  ` <el-form-item :label="${labelExpr}" prop="${prop}">`,
2101
2166
  ` <el-input-number v-model="form.${prop}" :min="0"${max}${precision} :placeholder="formInputPlaceholder(${labelExpr}, ${disabledBool})" style="width: 100%"${disabledAttr} />`,
2102
2167
  ' </el-form-item>',
2103
2168
  ' </el-col>',
2104
- ].join('\n');
2105
- }
2106
-
2107
- if (field.formType === 'datetime' || field.formType === 'date') {
2169
+ ].join('\n');
2170
+ }
2171
+
2172
+ if (field.formType === 'microme-operator') {
2173
+ return [
2174
+ renderFieldCommentV2(field),
2175
+ ` <el-col :span="12" class="mb20">`,
2176
+ ` <el-form-item :label="${labelExpr}" prop="${prop}">`,
2177
+ ` <MicromeOperator v-model="form.${prop}"${renderMicromeFormatAttr(field)} :placeholder="formInputPlaceholder(${labelExpr}, ${disabledBool})"${disabledAttr} />`,
2178
+ ' </el-form-item>',
2179
+ ' </el-col>',
2180
+ ].join('\n');
2181
+ }
2182
+
2183
+ if (field.formType === 'microme-operator') {
2184
+ return [
2185
+ renderFieldCommentV2(field),
2186
+ ' <el-col :span="12" class="mb20">',
2187
+ ` <el-form-item :label="${labelExpr}" prop="${prop}">`,
2188
+ ` <MicromeOperator v-model="form.${prop}"${renderMicromeFormatAttr(field)} :placeholder="formInputPlaceholder(${labelExpr}, ${disabledBool})"${disabledAttr} />`,
2189
+ ' </el-form-item>',
2190
+ ' </el-col>',
2191
+ ].join('\n');
2192
+ }
2193
+
2194
+ if (field.formType === 'datetime' || field.formType === 'date') {
2108
2195
  const pickerType = field.formType === 'datetime' ? 'datetime' : 'date';
2109
2196
  const formatName = field.formType === 'datetime' ? 'dateTimeStr' : 'dateStr';
2110
2197
  return [
@@ -2416,7 +2503,7 @@ function renderMultiLevelFormVue(model, moduleModel) {
2416
2503
  ` tenantId: Session.getTenant(),`,
2417
2504
  ].join('\n');
2418
2505
  const rules = renderFormRulesV2(moduleModel.visibleFields);
2419
- return `<template>
2506
+ return `<template>
2420
2507
  <el-dialog v-model="visible" :title="form.${moduleModel.pk.attrName} ? t('common.editBtn') : t('common.addBtn')" :close-on-click-modal="false" draggable>
2421
2508
  <el-form ref="dataFormRef" :model="form" :rules="dataRules" label-width="100px" v-loading="loading">
2422
2509
  <el-row :gutter="24">
@@ -2677,10 +2764,10 @@ function renderMultiLevelIndexVue(model) {
2677
2764
  )
2678
2765
  .join('\n');
2679
2766
 
2680
- return `<template>
2681
- <div class="layout-padding">
2682
- <!-- \u529f\u80fd\u540d\u79f0\uFF1A${model.featureTitle.replace(/--/g, '')} -->
2683
- <div class="multi-level-dict-layout">
2767
+ return `<!-- 功能名称:${sanitizeHtmlComment(model.featureTitle)} -->
2768
+ <template>
2769
+ <div class="layout-padding">
2770
+ <div class="multi-level-dict-layout">
2684
2771
  <div class="multi-level-left">
2685
2772
  ${renderMultiLevelSchemaListSlot('level1Config', 'activeLevel1Key', 'activeLevel1Module')}
2686
2773
  </div>
@@ -3068,6 +3155,10 @@ function sanitizeComment(value) {
3068
3155
  return String(value || '').replace(/\*\//g, '* /').replace(/\r?\n/g, ' ').trim();
3069
3156
  }
3070
3157
 
3158
+ function sanitizeHtmlComment(value) {
3159
+ return String(value || '').replace(/--/g, '').replace(/\r?\n/g, ' ').trim();
3160
+ }
3161
+
3071
3162
  function renderExtraApiFunctions(model) {
3072
3163
  if (!Array.isArray(model.extraApis) || !model.extraApis.length) return '';
3073
3164
  return model.extraApis
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "worsoft-frontend-codegen-local-mcp",
3
- "version": "0.1.60",
3
+ "version": "0.1.64",
4
4
  "description": "Worsoft frontend local-template code generation MCP server.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "worsoft <sw@worsoft.vip>",