worsoft-frontend-codegen-local-mcp 0.1.20 → 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/MVP_DESIGN.md +58 -39
- package/README.md +54 -68
- package/mcp_server.js +363 -532
- package/package.json +1 -1
package/MVP_DESIGN.md
CHANGED
|
@@ -2,25 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
## Goal
|
|
4
4
|
|
|
5
|
-
Build a
|
|
6
|
-
|
|
5
|
+
Build a local MCP plugin that generates frontend files from:
|
|
6
|
+
|
|
7
|
+
- API-first structured metadata
|
|
7
8
|
- local template assets
|
|
8
9
|
- style-based template selection
|
|
9
10
|
|
|
10
|
-
without depending on the Worsoft backend generation API
|
|
11
|
-
|
|
12
|
-
##
|
|
13
|
-
|
|
14
|
-
1.
|
|
15
|
-
2.
|
|
16
|
-
3.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
without depending on the Worsoft backend generation API
|
|
12
|
+
|
|
13
|
+
## Current Supported Flow
|
|
14
|
+
|
|
15
|
+
1. Caller-side skill reads API doc and requirement doc
|
|
16
|
+
2. Caller-side skill builds structured metadata
|
|
17
|
+
3. MCP receives:
|
|
18
|
+
- main table metadata
|
|
19
|
+
- child table metadata
|
|
20
|
+
- explicit `payloadField`
|
|
21
|
+
- field arrays
|
|
22
|
+
4. MCP loads style metadata from `assets/style-catalog.json`
|
|
23
|
+
5. MCP resolves shared template selection for the requested `style`
|
|
24
|
+
6. MCP builds a normalized runtime model
|
|
25
|
+
7. MCP maps structured fields into frontend field types
|
|
26
|
+
8. MCP renders runtime templates
|
|
27
|
+
9. MCP returns a render manifest
|
|
28
|
+
10. MCP optionally writes files
|
|
24
29
|
|
|
25
30
|
## Declared Styles
|
|
26
31
|
|
|
@@ -38,19 +43,34 @@ without depending on the Worsoft backend generation API.
|
|
|
38
43
|
|
|
39
44
|
```json
|
|
40
45
|
{
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
+
"featureTitle": "外包人员登记",
|
|
47
|
+
"tableName": "iwm_emp_outsource_person",
|
|
48
|
+
"tableComment": "外包人员登记表",
|
|
49
|
+
"apiPath": "iwmEmpOutsourcePerson",
|
|
50
|
+
"style": "master_child_jump",
|
|
46
51
|
"fields": [
|
|
47
52
|
{
|
|
48
|
-
"fieldName": "
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
53
|
+
"fieldName": "name",
|
|
54
|
+
"label": "姓名",
|
|
55
|
+
"type": "String",
|
|
56
|
+
"required": true,
|
|
57
|
+
"readonly": false,
|
|
58
|
+
"show": true,
|
|
59
|
+
"length": 30,
|
|
60
|
+
"dictType": "",
|
|
61
|
+
"description": "姓名",
|
|
62
|
+
"sourceKind": "entity"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"children": [
|
|
66
|
+
{
|
|
67
|
+
"childTableName": "iwm_emp_outsource_person_certificate",
|
|
68
|
+
"childTableComment": "外包人员证书表",
|
|
69
|
+
"payloadField": "certificateList",
|
|
70
|
+
"mainField": "id",
|
|
71
|
+
"childField": "outsourcePersonId",
|
|
72
|
+
"relationType": "1:N",
|
|
73
|
+
"fields": []
|
|
54
74
|
}
|
|
55
75
|
]
|
|
56
76
|
}
|
|
@@ -58,21 +78,20 @@ without depending on the Worsoft backend generation API.
|
|
|
58
78
|
|
|
59
79
|
## Master-Child Contract
|
|
60
80
|
|
|
61
|
-
When `style=master_child_jump
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
81
|
+
When `style=master_child_jump`:
|
|
82
|
+
|
|
83
|
+
- MCP never infers child relations
|
|
84
|
+
- caller must always pass explicit `children[]`
|
|
85
|
+
- `payloadField` is the only child list truth
|
|
65
86
|
|
|
66
87
|
## Risks
|
|
67
88
|
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
- Query/list/form metadata inference
|
|
71
|
-
- Multi-child relations still need explicit disambiguation.
|
|
89
|
+
- Quality now depends on caller-side extraction from API doc and requirement doc
|
|
90
|
+
- If API doc omits structure or dict codes, caller-side skill must stop and report the gap
|
|
91
|
+
- Query/list/form metadata inference still contains heuristics for widths and control defaults
|
|
72
92
|
|
|
73
93
|
## Next Steps
|
|
74
94
|
|
|
75
|
-
1.
|
|
76
|
-
2.
|
|
77
|
-
3.
|
|
78
|
-
4. Consider cross-checking Markdown definitions against SQL or DB metadata
|
|
95
|
+
1. Continue hardening API-first extraction rules on caller-side skills
|
|
96
|
+
2. Expand structured validation for field completeness
|
|
97
|
+
3. Keep template behavior aligned with API-first contract
|
package/README.md
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
# Worsoft Frontend Codegen Local MCP
|
|
2
2
|
|
|
3
|
-
This MCP generates Worsoft frontend files from
|
|
3
|
+
This MCP generates Worsoft frontend files from API-first structured metadata.
|
|
4
4
|
|
|
5
5
|
## Scope
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- API-first structured input
|
|
8
8
|
- style-based template selection
|
|
9
9
|
- local template rendering
|
|
10
10
|
- single-table runtime generation
|
|
11
|
-
- master-child runtime generation with
|
|
11
|
+
- master-child runtime generation with explicit `children[]`
|
|
12
12
|
- optional write-to-disk
|
|
13
13
|
|
|
14
14
|
## Current Inputs
|
|
15
15
|
|
|
16
|
-
- `
|
|
16
|
+
- `featureTitle`
|
|
17
17
|
- `tableName`
|
|
18
|
+
- `tableComment`
|
|
19
|
+
- `apiPath`
|
|
18
20
|
- `style`
|
|
21
|
+
- `fields`
|
|
22
|
+
- `children`
|
|
19
23
|
- `frontendPath`
|
|
20
24
|
- `moduleName`
|
|
21
25
|
- `writeToDisk`
|
|
22
26
|
- `overwrite`
|
|
23
|
-
- `childTableName` when `style=master_child_jump`: required
|
|
24
|
-
- `mainField` when `style=master_child_jump`: required
|
|
25
|
-
- `childField` when `style=master_child_jump`: required
|
|
26
|
-
- `relationType` when `style=master_child_jump`: optional
|
|
27
|
-
- `children` when `style=master_child_jump`: optional array of direct child relations; when provided it overrides the legacy single-child fields
|
|
28
27
|
|
|
29
28
|
## Recommended MCP Arguments
|
|
30
29
|
|
|
@@ -32,9 +31,17 @@ Single table:
|
|
|
32
31
|
|
|
33
32
|
```json
|
|
34
33
|
{
|
|
35
|
-
"
|
|
34
|
+
"featureTitle": "劳务公司管理",
|
|
35
|
+
"tableName": "iwm_out_labor_company",
|
|
36
|
+
"tableComment": "劳务公司信息表",
|
|
37
|
+
"apiPath": "iwmOutLaborCompany",
|
|
36
38
|
"style": "single_table_dialog",
|
|
37
|
-
"
|
|
39
|
+
"fields": [
|
|
40
|
+
{ "fieldName": "id", "label": "主键", "type": "Long", "show": false },
|
|
41
|
+
{ "fieldName": "companyName", "label": "劳务公司名称", "type": "String", "required": true, "length": 120 },
|
|
42
|
+
{ "fieldName": "status", "label": "状态", "type": "String", "dictType": "labor_company_status", "length": 32 }
|
|
43
|
+
],
|
|
44
|
+
"children": [],
|
|
38
45
|
"frontendPath": "E:/own-worker-platform/trunk/worsoft-ui",
|
|
39
46
|
"moduleName": "admin/test",
|
|
40
47
|
"writeToDisk": false
|
|
@@ -45,40 +52,30 @@ Master-child:
|
|
|
45
52
|
|
|
46
53
|
```json
|
|
47
54
|
{
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"childField": "trade_id",
|
|
53
|
-
"relationType": "1:N",
|
|
54
|
-
"designFile": "plugins/sql/SQL 设计说明.md",
|
|
55
|
-
"frontendPath": "E:/own-worker-platform/trunk/worsoft-ui",
|
|
56
|
-
"moduleName": "admin/test",
|
|
57
|
-
"writeToDisk": false
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
Multi direct children on one main form:
|
|
62
|
-
|
|
63
|
-
```json
|
|
64
|
-
{
|
|
65
|
-
"tableName": "iwm_sys_trade_level",
|
|
55
|
+
"featureTitle": "外包人员登记",
|
|
56
|
+
"tableName": "iwm_emp_outsource_person",
|
|
57
|
+
"tableComment": "外包人员登记表",
|
|
58
|
+
"apiPath": "iwmEmpOutsourcePerson",
|
|
66
59
|
"style": "master_child_jump",
|
|
60
|
+
"fields": [
|
|
61
|
+
{ "fieldName": "id", "label": "主键", "type": "Long", "show": false },
|
|
62
|
+
{ "fieldName": "name", "label": "姓名", "type": "String", "required": true, "length": 30 },
|
|
63
|
+
{ "fieldName": "employeeStatus", "label": "人员状态", "type": "String", "dictType": "employee_status", "length": 32 }
|
|
64
|
+
],
|
|
67
65
|
"children": [
|
|
68
66
|
{
|
|
69
|
-
"childTableName": "
|
|
67
|
+
"childTableName": "iwm_emp_outsource_person_certificate",
|
|
68
|
+
"childTableComment": "外包人员证书表",
|
|
69
|
+
"payloadField": "certificateList",
|
|
70
70
|
"mainField": "id",
|
|
71
|
-
"childField": "
|
|
72
|
-
"relationType": "1:N"
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
"childField": "trade_level_id",
|
|
78
|
-
"relationType": "1:N"
|
|
71
|
+
"childField": "outsourcePersonId",
|
|
72
|
+
"relationType": "1:N",
|
|
73
|
+
"fields": [
|
|
74
|
+
{ "fieldName": "id", "label": "主键", "type": "Long", "show": false },
|
|
75
|
+
{ "fieldName": "certificateId", "label": "证件名称ID", "type": "Long", "required": true }
|
|
76
|
+
]
|
|
79
77
|
}
|
|
80
78
|
],
|
|
81
|
-
"designFile": "plugins/sql/SQL 璁捐璇存槑.md",
|
|
82
79
|
"frontendPath": "E:/own-worker-platform/trunk/worsoft-ui",
|
|
83
80
|
"moduleName": "admin/test",
|
|
84
81
|
"writeToDisk": false
|
|
@@ -92,9 +89,7 @@ PowerShell:
|
|
|
92
89
|
```powershell
|
|
93
90
|
powershell -ExecutionPolicy Bypass -File plugins/worsoft-codegen-local/smoke_test_mcp.ps1 -Scenario single
|
|
94
91
|
powershell -ExecutionPolicy Bypass -File plugins/worsoft-codegen-local/smoke_test_mcp.ps1 -Scenario master
|
|
95
|
-
powershell -ExecutionPolicy Bypass -File plugins/worsoft-codegen-local/smoke_test_mcp.ps1 -Scenario child
|
|
96
92
|
powershell -ExecutionPolicy Bypass -File plugins/worsoft-codegen-local/smoke_test_mcp.ps1 -Scenario multi
|
|
97
|
-
powershell -ExecutionPolicy Bypass -File plugins/worsoft-codegen-local/smoke_test_mcp.ps1 -Scenario missing_relation
|
|
98
93
|
```
|
|
99
94
|
|
|
100
95
|
Node:
|
|
@@ -102,42 +97,33 @@ Node:
|
|
|
102
97
|
```bash
|
|
103
98
|
node plugins/worsoft-codegen-local/smoke_test_mcp.js --scenario single
|
|
104
99
|
node plugins/worsoft-codegen-local/smoke_test_mcp.js --scenario master
|
|
105
|
-
node plugins/worsoft-codegen-local/smoke_test_mcp.js --scenario child
|
|
106
100
|
node plugins/worsoft-codegen-local/smoke_test_mcp.js --scenario multi
|
|
107
|
-
node plugins/worsoft-codegen-local/smoke_test_mcp.js --scenario missing_relation
|
|
108
101
|
```
|
|
109
102
|
|
|
110
103
|
Optional overrides:
|
|
111
104
|
|
|
112
|
-
- `--design-file`
|
|
113
105
|
- `--table-name`
|
|
106
|
+
- `--table-comment`
|
|
107
|
+
- `--feature-title`
|
|
108
|
+
- `--api-path`
|
|
114
109
|
- `--style`
|
|
115
|
-
- `--child-table-name`
|
|
116
|
-
- `--main-field`
|
|
117
|
-
- `--child-field`
|
|
118
|
-
- `--relation-type`
|
|
119
110
|
- `--frontend-path`
|
|
120
111
|
- `--write-to-disk`
|
|
121
112
|
|
|
122
113
|
## Master-Child Contract
|
|
123
114
|
|
|
124
|
-
For `master_child_jump`, MCP does not infer relations
|
|
125
|
-
|
|
126
|
-
The caller must provide:
|
|
115
|
+
For `master_child_jump`, MCP does not infer relations.
|
|
127
116
|
|
|
128
|
-
|
|
129
|
-
- or the legacy single-child fields: `childTableName`, `mainField`, `childField`
|
|
117
|
+
The caller must provide explicit `children[]`, and each child must include:
|
|
130
118
|
|
|
131
|
-
|
|
119
|
+
- `childTableName`
|
|
120
|
+
- `childTableComment`
|
|
121
|
+
- `payloadField`
|
|
122
|
+
- `mainField`
|
|
123
|
+
- `childField`
|
|
124
|
+
- `fields`
|
|
132
125
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
```json
|
|
136
|
-
{
|
|
137
|
-
"type": "relation_input_required",
|
|
138
|
-
"requiredFields": ["childTableName", "mainField", "childField"]
|
|
139
|
-
}
|
|
140
|
-
```
|
|
126
|
+
If these fields are missing, MCP returns a structured validation error.
|
|
141
127
|
|
|
142
128
|
## Current Outputs
|
|
143
129
|
|
|
@@ -145,6 +131,7 @@ Example:
|
|
|
145
131
|
- `src/views/<module>/<function>/form.vue`
|
|
146
132
|
- `src/views/<module>/<function>/options.ts`
|
|
147
133
|
- `src/api/<module>/<function>.ts`
|
|
134
|
+
- `src/i18n/biz/<module>/<function>.zh-cn.ts`
|
|
148
135
|
- `menu/<function>_menu.sql`
|
|
149
136
|
|
|
150
137
|
## Style Catalog
|
|
@@ -160,12 +147,11 @@ Declared styles:
|
|
|
160
147
|
|
|
161
148
|
## Notes
|
|
162
149
|
|
|
163
|
-
- Shared Worsoft template references live under `../template
|
|
164
|
-
- Plugin-local runtime assets live under `assets/templates
|
|
165
|
-
-
|
|
166
|
-
-
|
|
167
|
-
-
|
|
168
|
-
- Menu SQL is emitted to `frontendPath/menu/`.
|
|
150
|
+
- Shared Worsoft template references live under `../template`
|
|
151
|
+
- Plugin-local runtime assets live under `assets/templates`
|
|
152
|
+
- API-first means MCP no longer reads Markdown design docs or SQL design docs
|
|
153
|
+
- Caller-side skills are responsible for turning API doc + requirement doc into structured arguments
|
|
154
|
+
- Menu SQL is emitted to `frontendPath/menu/`
|
|
169
155
|
|
|
170
156
|
## IDE Guide
|
|
171
157
|
|