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 CHANGED
@@ -2,25 +2,30 @@
2
2
 
3
3
  ## Goal
4
4
 
5
- Build a parallel MCP plugin that generates frontend files from:
6
- - local Markdown design docs
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
- ## First Supported Flow
13
-
14
- 1. Read `designFile` or fall back to `plugins/sql/SQL 设计说明.md`
15
- 2. Parse one table definition by `tableName`
16
- 3. Load style metadata from `assets/style-catalog.json`
17
- 4. Resolve the shared template selection for the requested `style`
18
- 5. Build a normalized metadata model
19
- 6. For `master_child_jump`, infer the child relation from the design doc when possible
20
- 7. Map parsed fields into simple frontend field types
21
- 8. Render plugin-local runtime templates when the style is implemented
22
- 9. Return a render manifest
23
- 10. Optionally write files
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
- "tableName": "iwm_sys_trade",
42
- "className": "IwmSysTrade",
43
- "functionName": "iwmSysTrade",
44
- "moduleName": "admin/test",
45
- "pk": { "fieldName": "id", "attrName": "id" },
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": "trade_name",
49
- "attrName": "tradeName",
50
- "sqlType": "VARCHAR",
51
- "comment": "Trade Name",
52
- "formType": "text",
53
- "isAudit": false
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`, local mode now prefers the Markdown design file contract:
62
- - parse child relations from the "主从表关联说明" section
63
- - auto-resolve `mainField` and `childField`
64
- - require `childTableName` only when one main table has multiple child relations
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
- - Existing shared templates use Velocity syntax and need a larger rendering engine.
69
- - Markdown design docs may drift from the real schema if they are not maintained.
70
- - Query/list/form metadata inference is heuristic in local mode.
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. Add query/grid heuristics
76
- 2. Add dict config sidecar file support
77
- 3. Decide whether to migrate shared templates into a neutral local template format
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 a local Markdown design document.
3
+ This MCP generates Worsoft frontend files from API-first structured metadata.
4
4
 
5
5
  ## Scope
6
6
 
7
- - local Markdown design file input
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 caller-provided relation input
11
+ - master-child runtime generation with explicit `children[]`
12
12
  - optional write-to-disk
13
13
 
14
14
  ## Current Inputs
15
15
 
16
- - `designFile`: optional, defaults to `../sql/SQL 设计说明.md`
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
- "tableName": "iwm_sys_trade",
34
+ "featureTitle": "劳务公司管理",
35
+ "tableName": "iwm_out_labor_company",
36
+ "tableComment": "劳务公司信息表",
37
+ "apiPath": "iwmOutLaborCompany",
36
38
  "style": "single_table_dialog",
37
- "designFile": "plugins/sql/SQL 设计说明.md",
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
- "tableName": "iwm_sys_trade",
49
- "style": "master_child_jump",
50
- "childTableName": "iwm_sys_trade_level",
51
- "mainField": "id",
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": "iwm_sys_trade_level_standard",
67
+ "childTableName": "iwm_emp_outsource_person_certificate",
68
+ "childTableComment": "外包人员证书表",
69
+ "payloadField": "certificateList",
70
70
  "mainField": "id",
71
- "childField": "trade_level_id",
72
- "relationType": "1:N"
73
- },
74
- {
75
- "childTableName": "iwm_sys_trade_level_competency",
76
- "mainField": "id",
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 from the design file anymore.
125
-
126
- The caller must provide:
115
+ For `master_child_jump`, MCP does not infer relations.
127
116
 
128
- - either `children[]`
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
- If these fields are missing, MCP returns `relation_input_required`.
119
+ - `childTableName`
120
+ - `childTableComment`
121
+ - `payloadField`
122
+ - `mainField`
123
+ - `childField`
124
+ - `fields`
132
125
 
133
- Example:
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
- - The preferred source is `plugins/sql/SQL 设计说明.md`.
166
- - Markdown parsing is used for field-definition tables.
167
- - Master-child relation parsing is handled outside MCP and passed in through tool arguments.
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