worsoft-frontend-codegen-local-mcp 0.1.89 → 0.1.90

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.
Files changed (2) hide show
  1. package/mcp_server.js +36 -13
  2. package/package.json +1 -1
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.89';
8
+ const SERVER_VERSION = '0.1.90';
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');
@@ -2208,13 +2208,35 @@ function buildModel(safeArgs) {
2208
2208
  };
2209
2209
  }
2210
2210
 
2211
- function renderTemplate(templateText, replacements) {
2212
- let output = templateText;
2213
- for (const [key, value] of Object.entries(replacements)) {
2214
- output = output.split('{{' + key + '}}').join(String(value));
2215
- }
2216
- return output;
2217
- }
2211
+ function renderTemplate(templateText, replacements) {
2212
+ let output = templateText;
2213
+ for (const [key, value] of Object.entries(replacements)) {
2214
+ output = output.split('{{' + key + '}}').join(String(value));
2215
+ }
2216
+ return output;
2217
+ }
2218
+
2219
+ function findUnresolvedTemplatePlaceholders(content) {
2220
+ const matches = String(content || '').match(/\{\{[A-Z][A-Z0-9_]*\}\}/g) || [];
2221
+ return [...new Set(matches)];
2222
+ }
2223
+
2224
+ function assertNoUnresolvedTemplatePlaceholders(files) {
2225
+ const issues = files
2226
+ .map((file) => ({
2227
+ type: file.type,
2228
+ path: file.path,
2229
+ placeholders: findUnresolvedTemplatePlaceholders(file.content),
2230
+ }))
2231
+ .filter((item) => item.placeholders.length);
2232
+
2233
+ if (issues.length) {
2234
+ const detail = issues
2235
+ .map((item) => `${item.type}:${path.basename(item.path)} -> ${item.placeholders.join(', ')}`)
2236
+ .join('; ');
2237
+ throw new Error(`MCP template rendering left unresolved placeholders: ${detail}`);
2238
+ }
2239
+ }
2218
2240
 
2219
2241
  function renderFormField(field) {
2220
2242
  const label = stripDictAnnotation(field.comment).replace(/'/g, "\\'");
@@ -4434,11 +4456,12 @@ function renderFiles(model, stylePreset, sharedSupport, localeZhSupport) {
4434
4456
  },
4435
4457
  ];
4436
4458
 
4437
- if (menuSqlTemplate) {
4438
- files.push({ type: 'menuSql', path: path.join(menuRoot, `${model.functionName}_menu.sql`), content: renderTemplate(menuSqlTemplate, replacements) });
4439
- }
4440
- return files;
4441
- }
4459
+ if (menuSqlTemplate) {
4460
+ files.push({ type: 'menuSql', path: path.join(menuRoot, `${model.functionName}_menu.sql`), content: renderTemplate(menuSqlTemplate, replacements) });
4461
+ }
4462
+ assertNoUnresolvedTemplatePlaceholders(files);
4463
+ return files;
4464
+ }
4442
4465
 
4443
4466
  function ensureArguments(input) {
4444
4467
  if (!input || typeof input !== 'object') throw new Error('Arguments must be an object');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "worsoft-frontend-codegen-local-mcp",
3
- "version": "0.1.89",
3
+ "version": "0.1.90",
4
4
  "description": "Worsoft frontend local-template code generation MCP server.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "worsoft <sw@worsoft.vip>",