@noleemits/vision-builder-control-mcp 4.41.1 → 4.42.0

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/index.js +134 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -2,7 +2,8 @@
2
2
  /**
3
3
  * Noleemits Vision Builder Control MCP Server
4
4
  *
5
- * Provides 67 tools for building and managing WordPress/Elementor sites.
5
+ * Provides 69 tools for building and managing WordPress/Elementor sites.
6
+ * v4.42.0: audit_text + replace_text — unified search/replace across Elementor + post columns with literal/regex/fuzzy modes. Fuzzy mode tolerates NBSP, curly quotes/dashes, ideographic punctuation — fixes the "copy-pasted needle won't match" bug.
6
7
  * v4.35.0: PixelVault image integration — pixelvault_status, find_images, generate_image, get_batch_status, insert_image tools; proxy REST endpoints at /nvbc/v1/pixelvault/*.
7
8
  * v4.34.0: Design tokens auto-inject as CSS custom properties (--nvbc-color-*, --nvbc-fs-*, --nvbc-space-*) site-wide via wp_head; kit global CSS tools (get_kit_global_css, set_kit_global_css); get_kit_settings formatter handles gap-style objects.
8
9
  * v4.33.0: Elementor kit layout settings (get_kit_settings, set_kit_settings) — read/write container_width, viewports, gutter.
@@ -107,7 +108,7 @@ process.on('SIGINT', () => {
107
108
  // CONFIG
108
109
  // ================================================================
109
110
 
110
- const VERSION = '4.41.1';
111
+ const VERSION = '4.42.0';
111
112
  const MIN_PLUGIN_VERSION = '4.13.0'; // Minimum WP plugin version required by this MCP server
112
113
 
113
114
  // ================================================================
@@ -3067,6 +3068,42 @@ function getToolDefinitions() {
3067
3068
  required: ['search', 'replace']
3068
3069
  }
3069
3070
  },
3071
+ {
3072
+ name: 'audit_text',
3073
+ description: 'Unified text search across Elementor (full settings tree, every string value), post_content, post_title, and post_excerpt. The fuzzy mode tolerates unicode whitespace and punctuation variants — use it when a literal copy-pasted string mysteriously fails to match (NBSP between words, curly quotes/dashes/periods inserted by builders, etc.). Read-only.',
3074
+ inputSchema: {
3075
+ type: 'object',
3076
+ properties: {
3077
+ search: { type: 'string', description: 'Text or pattern to find.' },
3078
+ mode: { type: 'string', enum: ['literal', 'regex', 'fuzzy'], description: '"literal" (exact bytes), "regex" (PHP regex without delimiters, u flag forced), or "fuzzy" (tolerates NBSP, curly quotes/dashes/periods, ideographic whitespace). Default: literal.' },
3079
+ case_insensitive: { type: 'boolean', description: 'Ignore case. Default: false.' },
3080
+ stores: { type: 'array', items: { type: 'string', enum: ['elementor', 'post_content', 'post_title', 'post_excerpt'] }, description: 'Which stores to scan. Default: all four. Pass [\"elementor\"] to limit scope.' },
3081
+ post_type: { type: 'string', description: '"post", "page", "any", or a specific CPT slug. Default: any.' },
3082
+ include_drafts: { type: 'boolean', description: 'Include draft/private/pending posts. Default: true.' },
3083
+ limit: { type: 'number', description: 'Max posts to scan per store (default 1000, max 5000).' }
3084
+ },
3085
+ required: ['search']
3086
+ }
3087
+ },
3088
+ {
3089
+ name: 'replace_text',
3090
+ description: 'Unified bulk find/replace across Elementor (entire settings tree), post_content, post_title, and post_excerpt. Same matching modes as audit_text — fuzzy mode is the fix for the "copy-pasted needle won\'t match" class of bug. ALWAYS dry_run=true first. Never changes post_modified date.',
3091
+ inputSchema: {
3092
+ type: 'object',
3093
+ properties: {
3094
+ search: { type: 'string', description: 'Text or pattern to find.' },
3095
+ replace: { type: 'string', description: 'Replacement text. For regex/fuzzy modes, $1 etc. work as backreferences in regex mode only.' },
3096
+ mode: { type: 'string', enum: ['literal', 'regex', 'fuzzy'], description: '"literal", "regex", or "fuzzy". Default: literal.' },
3097
+ case_insensitive: { type: 'boolean', description: 'Ignore case. Default: false.' },
3098
+ stores: { type: 'array', items: { type: 'string', enum: ['elementor', 'post_content', 'post_title', 'post_excerpt'] }, description: 'Stores to operate on. Default: all four.' },
3099
+ post_type: { type: 'string', description: '"post", "page", "any", CPT slug. Default: any.' },
3100
+ include_drafts: { type: 'boolean', description: 'Include draft/private/pending. Default: true.' },
3101
+ limit: { type: 'number', description: 'Max posts per store. Default 1000, max 5000.' },
3102
+ dry_run: { type: 'boolean', description: 'Preview without saving. Default: true (SAFE).' }
3103
+ },
3104
+ required: ['search', 'replace']
3105
+ }
3106
+ },
3070
3107
  {
3071
3108
  name: 'set_faq_schema',
3072
3109
  description: 'Set FAQPage JSON-LD schema on a single post. Stores in post meta and auto-injects into page head. Use for adding FAQ rich snippets to posts with Q&A content.',
@@ -5325,6 +5362,101 @@ async function handleToolCall(name, args) {
5325
5362
  return ok(out);
5326
5363
  }
5327
5364
 
5365
+ case 'audit_text': {
5366
+ const body = { search: stripCDATA(args.search) };
5367
+ if (args.mode) body.mode = args.mode;
5368
+ if (args.case_insensitive) body.case_insensitive = parseBool(args.case_insensitive, false);
5369
+ if (args.stores) body.stores = args.stores;
5370
+ if (args.post_type) body.post_type = args.post_type;
5371
+ if (args.include_drafts !== undefined) body.include_drafts = parseBool(args.include_drafts, true);
5372
+ if (args.limit) body.limit = args.limit;
5373
+ const r = await apiCall('/audit-text', 'POST', body);
5374
+ if (r.code || r.error) return ok(`Failed: ${r.message || r.error || 'Unknown error'}`);
5375
+ const s = r.summary || { total_matches: 0, posts_affected: 0, by_store: {} };
5376
+ let out = `=== AUDIT TEXT (${r.mode || 'literal'}${r.case_insensitive ? ', ci' : ''}) ===\n`;
5377
+ out += `Search: "${r.search}"\n`;
5378
+ out += `Stores: ${(r.stores || []).join(', ')}\n`;
5379
+ out += `Total matches: ${s.total_matches} | Posts affected: ${s.posts_affected}\n`;
5380
+ if (s.by_store && Object.keys(s.by_store).length) {
5381
+ out += `By store: ${Object.entries(s.by_store).map(([k,v]) => `${k}=${v}`).join(', ')}\n`;
5382
+ }
5383
+ if (!r.matches?.length) {
5384
+ out += '\nNo matches found.';
5385
+ if (r.mode !== 'fuzzy') out += '\n💡 Try mode="fuzzy" to tolerate NBSP / curly punctuation.';
5386
+ return ok(out);
5387
+ }
5388
+ // Group by post for readability
5389
+ const groups = {};
5390
+ r.matches.forEach(m => {
5391
+ const key = `${m.post_id}|${m.post_title || ''}`;
5392
+ (groups[key] = groups[key] || []).push(m);
5393
+ });
5394
+ Object.entries(groups).slice(0, 50).forEach(([key, ms]) => {
5395
+ const [pid, title] = key.split('|');
5396
+ out += `\n--- [${pid}] ${title} — ${ms.length} match(es) ---\n`;
5397
+ ms.slice(0, 10).forEach(m => {
5398
+ if (m.store === 'elementor') {
5399
+ out += ` [elementor.${m.widget || '?'}] ${m.element_id}.${m.field || ''}\n`;
5400
+ } else {
5401
+ out += ` [${m.store}] ${m.field || ''}\n`;
5402
+ }
5403
+ out += ` raw: "${(m.raw_match || '').slice(0, 80).replace(/\n/g, ' ')}"\n`;
5404
+ out += ` ctx: ${(m.context || '').slice(0, 160)}\n`;
5405
+ });
5406
+ if (ms.length > 10) out += ` … and ${ms.length - 10} more\n`;
5407
+ });
5408
+ if (Object.keys(groups).length > 50) out += `\n…and ${Object.keys(groups).length - 50} more posts (truncated)`;
5409
+ return ok(out);
5410
+ }
5411
+
5412
+ case 'replace_text': {
5413
+ const body = {
5414
+ search: stripCDATA(args.search),
5415
+ replace: stripCDATA(args.replace),
5416
+ dry_run: parseBool(args.dry_run, true),
5417
+ };
5418
+ if (args.mode) body.mode = args.mode;
5419
+ if (args.case_insensitive) body.case_insensitive = parseBool(args.case_insensitive, false);
5420
+ if (args.stores) body.stores = args.stores;
5421
+ if (args.post_type) body.post_type = args.post_type;
5422
+ if (args.include_drafts !== undefined) body.include_drafts = parseBool(args.include_drafts, true);
5423
+ if (args.limit) body.limit = args.limit;
5424
+ const r = await apiCall('/replace-text', 'POST', body);
5425
+ if (r.code || r.error) return ok(`Failed: ${r.message || r.error || 'Unknown error'}`);
5426
+ const s = r.summary || { total_matches: 0, posts_affected: 0, by_store: {} };
5427
+ const tag = r.dry_run ? 'DRY RUN' : 'APPLIED';
5428
+ let out = `=== REPLACE TEXT (${tag} · ${r.mode || 'literal'}${r.case_insensitive ? ', ci' : ''}) ===\n`;
5429
+ out += `Search: "${r.search}"\nReplace: "${r.replace}"\n`;
5430
+ out += `Stores: ${(r.stores || []).join(', ')}\n`;
5431
+ out += `Total matches: ${s.total_matches} | Posts affected: ${s.posts_affected}\n`;
5432
+ if (s.by_store && Object.keys(s.by_store).length) {
5433
+ out += `By store: ${Object.entries(s.by_store).map(([k,v]) => `${k}=${v}`).join(', ')}\n`;
5434
+ }
5435
+ if (!r.matches?.length) {
5436
+ out += '\nNo matches found.';
5437
+ if (r.mode !== 'fuzzy') out += '\n💡 Try mode="fuzzy" to tolerate NBSP / curly punctuation.';
5438
+ return ok(out);
5439
+ }
5440
+ const groups = {};
5441
+ r.matches.forEach(m => {
5442
+ const key = `${m.post_id}|${m.post_title || ''}`;
5443
+ (groups[key] = groups[key] || []).push(m);
5444
+ });
5445
+ Object.entries(groups).slice(0, 50).forEach(([key, ms]) => {
5446
+ const [pid, title] = key.split('|');
5447
+ out += `\n--- [${pid}] ${title} — ${ms.length} change(s) ---\n`;
5448
+ ms.slice(0, 8).forEach(m => {
5449
+ const loc = m.store === 'elementor'
5450
+ ? `elementor.${m.widget || '?'} ${m.element_id}.${m.field || ''}`
5451
+ : `${m.store}`;
5452
+ out += ` [${loc}] "${(m.raw_match || '').slice(0, 60).replace(/\n/g, ' ')}"\n`;
5453
+ });
5454
+ if (ms.length > 8) out += ` … and ${ms.length - 8} more\n`;
5455
+ });
5456
+ if (r.dry_run) out += `\n(Dry run — no changes saved. Set dry_run=false to apply.)`;
5457
+ return ok(out);
5458
+ }
5459
+
5328
5460
  case 'set_faq_schema': {
5329
5461
  const body = { post_id: args.post_id, faqs: args.faqs };
5330
5462
  if (args.dry_run !== undefined) body.dry_run = args.dry_run;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noleemits/vision-builder-control-mcp",
3
- "version": "4.41.1",
3
+ "version": "4.42.0",
4
4
  "description": "Vision Builder Control MCP server - design token-driven page builder tools for WordPress/Elementor websites",
5
5
  "type": "module",
6
6
  "main": "index.js",