feat: lit-site-status, Admin-Tab und Admin-Hinweis zeigen Divi-Fähigkeiten mit Zustand, Quelle, Problemen und betroffenen Werkzeugen
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
b92545a8fe
commit
2aef6e1154
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Integrations\Divi\Release;
|
||||
|
||||
use Closure;
|
||||
use LIT\MCP\Abilities\Ability;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/**
|
||||
* The per-feature view shared by lit-site-status and the admin tab (E3): each row of the compatibility matrix plus
|
||||
* the tools that need the feature. Reads the matrix the release gate already holds (cached, D7) – nothing is
|
||||
* checked again here.
|
||||
*/
|
||||
final class FeatureOverview
|
||||
{
|
||||
/** @param Closure(): list<Ability> $abilities All registered abilities (IntegrationRegistry::abilities()). */
|
||||
public function __construct(private Closure $abilities)
|
||||
{
|
||||
}
|
||||
|
||||
/** An overview that knows no tools (tests, and a Divi tab built without a registry). */
|
||||
public static function withoutTools(): self
|
||||
{
|
||||
return new self(static fn (): array => []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tools whose diviFeatures([]) contain the feature, named as the MCP client sees them: direct tools
|
||||
* lit-<name>, indirect ones lit/<name>. A tool that needs a feature only for certain input (content-create
|
||||
* with divi) is not listed – its refusal names the feature.
|
||||
*
|
||||
* @return array<string, list<string>> Feature ID => tool names.
|
||||
*/
|
||||
public function toolsByFeature(): array
|
||||
{
|
||||
$map = [];
|
||||
foreach (($this->abilities)() as $ability) {
|
||||
if (! $ability instanceof RequiresDiviFeatures) {
|
||||
continue;
|
||||
}
|
||||
foreach ($ability->diviFeatures([]) as $feature) {
|
||||
$map[$feature->value][] = $ability->isDirect()
|
||||
? str_replace('/', '-', $ability->name())
|
||||
: $ability->name();
|
||||
}
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{id: string, label: string, state: string, source: ?string, problems: list<string>,
|
||||
* tools: list<string>}>
|
||||
*/
|
||||
public function rows(CompatibilityMatrix $matrix): array
|
||||
{
|
||||
$tools = $this->toolsByFeature();
|
||||
|
||||
return array_map(
|
||||
static fn (array $row): array => $row + ['tools' => $tools[$row['id']] ?? []],
|
||||
$matrix->toArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user