Add SKILLS.md generator (derives full tool reference from Batch*.php)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q8t9GEyyLZbUQu26na1JQg
This commit is contained in:
2026-10-16 06:22:24 +00:00
parent 1afc9393a4
commit 701f569b6e
+32
View File
@@ -0,0 +1,32 @@
<?php
$dir = '/var/www/html/wp-content/plugins/advanced-mcp-plugin/';
if (!empty($argv[1])) $dir = rtrim($argv[1], '/') . '/';
$ext = $dir . 'includes/Extensions/';
$files = glob($ext . 'Batch*.php') ?: [];
natsort($files);
$out = "# Advanced MCP Plugin — Tool Reference\n\n";
$out .= "Auto-generated " . date('Y-m-d') . " from includes/Extensions/Batch*.php. Every integration family below is guarded: its tools register only on a site where the named plugin/constant is active. Regenerate with scripts/gen-skills.php.\n\n";
$total = 0; $fam = 0;
foreach ($files as $f) {
$b = basename($f, '.php');
$src = file_get_contents($f);
preg_match('/Batch\s*\d+\s*[\x{2014}\-]+\s*(.+?)\./u', $src, $hm);
$title = isset($hm[1]) ? trim($hm[1]) : $b;
$guard = '(unconditional)';
if (preg_match('/if\s*\(\s*!\s*(?:defined|class_exists)\s*\(\s*[\'"]\\\\?([A-Za-z0-9_\\\\]+)[\'"]/', $src, $gm)) $guard = ltrim($gm[1], '\\');
preg_match_all('/\$def\(\s*\'([a-z0-9_]+)\'\s*,\s*\'((?:\\\\.|[^\'\\\\])*)\'.*?,\s*\'(read|write|admin|woocommerce)\'\s*,/s', $src, $mm, PREG_SET_ORDER);
if (!$mm) continue;
$fam++;
$out .= "## {$b} — {$title}\nGuard: `{$guard}`\n\n";
foreach ($mm as $m) {
$name = $m[1];
$desc = str_replace(["\\'", "\\\\"], ["'", "\\"], $m[2]);
$scope = $m[3];
$out .= "- `{$name}` _({$scope})_ — {$desc}\n";
$total++;
}
$out .= "\n";
}
$out .= "---\n\nFamilies documented: {$fam}. Tools documented: {$total}. (Core WordPress/WooCommerce/Elementor baseline tools register unconditionally and are included above where they live in a BatchN file; the remaining baseline is visible via the live registry / Tools tab.)\n";
file_put_contents($dir . 'SKILLS.md', $out);
echo "SKILLS.md bytes=" . strlen($out) . " families={$fam} tools={$total}\n";