feat: Outline und Knoten zeigen Gruppen-Presets mit Namen
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
ca3bbf5ad1
commit
c3f08e2d33
@@ -10,6 +10,7 @@ use LIT\MCP\Abilities\Errors;
|
||||
use LIT\MCP\Abilities\JsonMap;
|
||||
use LIT\MCP\Abilities\Rev;
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\AttrMap;
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\Block;
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\NodeIndex;
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\NodeSummary;
|
||||
use LIT\MCP\Integrations\Divi\Design\DesignSystemReader;
|
||||
@@ -42,9 +43,9 @@ final class DiviNodeGetAbility implements Ability
|
||||
{
|
||||
return 'Liest einen Knoten der Divi-Seite vollständig: attrs als Attributpfad → Werte je Breakpoint '
|
||||
. '(Vollform, z. B. "title.decoration.font.font": {"desktop": {"value": {…}}}), die Kurzform-Werte, '
|
||||
. 'Presets und die IDs der Kinder. Pfad-IDs aus lit-divi-outline. Werte wie $variable(…)$ (globale '
|
||||
. 'Farben, Variablen, dynamische Inhalte) werden unverändert angezeigt, beim Schreiben aber erneut '
|
||||
. 'geprüft, nie ungeprüft übernommen.';
|
||||
. 'Presets, Gruppen-Presets und die IDs der Kinder. Pfad-IDs aus lit-divi-outline. Werte wie '
|
||||
. '$variable(…)$ (globale Farben, Variablen, dynamische Inhalte) werden unverändert angezeigt, beim '
|
||||
. 'Schreiben aber erneut geprüft, nie ungeprüft übernommen.';
|
||||
}
|
||||
|
||||
public function inputSchema(): array
|
||||
@@ -83,6 +84,27 @@ final class DiviNodeGetAbility implements Ability
|
||||
'required' => ['id', 'name'],
|
||||
],
|
||||
],
|
||||
'group_presets' => [
|
||||
'type' => 'array',
|
||||
'description' => 'Gruppen-Presets des Moduls: group_id = Attributpfad der Gruppe, group = '
|
||||
. 'Kurzname (Schlüssel für group_presets).',
|
||||
'items' => [
|
||||
'type' => 'object',
|
||||
'properties' => [
|
||||
'group_id' => ['type' => 'string'],
|
||||
'group' => ['type' => 'string'],
|
||||
'presets' => [
|
||||
'type' => 'array',
|
||||
'items' => [
|
||||
'type' => 'object',
|
||||
'properties' => ['id' => ['type' => 'string'], 'name' => ['type' => 'string']],
|
||||
'required' => ['id', 'name'],
|
||||
],
|
||||
],
|
||||
],
|
||||
'required' => ['group_id', 'group', 'presets'],
|
||||
],
|
||||
],
|
||||
'builder_version' => ['type' => ['string', 'null']],
|
||||
'children' => ['type' => 'array', 'items' => ['type' => 'string']],
|
||||
'global' => ['type' => ['object', 'null']],
|
||||
@@ -163,6 +185,7 @@ final class DiviNodeGetAbility implements Ability
|
||||
static fn (string $presetId): array => ['id' => $presetId, 'name' => $names[$presetId] ?? ''],
|
||||
NodeSummary::presetIds($block)
|
||||
),
|
||||
'group_presets' => $this->groupPresets($block, $names),
|
||||
'builder_version' => is_string($version) ? $version : null,
|
||||
'children' => $editable
|
||||
? array_values(array_filter(array_map([$page->index, 'idOf'], $block->children())))
|
||||
@@ -170,4 +193,26 @@ final class DiviNodeGetAbility implements Ability
|
||||
'global' => $global,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $names Preset ID => name.
|
||||
* @return list<array{group_id: string, group: string, presets: list<array{id: string, name: string}>}>
|
||||
*/
|
||||
private function groupPresets(Block $block, array $names): array
|
||||
{
|
||||
$groups = [];
|
||||
foreach (NodeSummary::groupPresets($block) as $groupId => $group) {
|
||||
$name = $group['groupName'];
|
||||
$groups[] = [
|
||||
'group_id' => $groupId,
|
||||
'group' => str_starts_with($name, 'divi/') ? substr($name, 5) : $name,
|
||||
'presets' => array_map(
|
||||
static fn (string $presetId): array => ['id' => $presetId, 'name' => $names[$presetId] ?? ''],
|
||||
$group['presetIds']
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ final class DiviOutlineAbility implements Ability
|
||||
public function description(): string
|
||||
{
|
||||
return 'Liest den Aufbau einer Divi-Seite: Knoten mit Pfad-ID (s0, s0.r1, s0.r1.c0.m2), Modultyp, '
|
||||
. 'Admin-Label, Textauszug und Preset. Liefert tree_rev – Pflicht für jede Divi-Änderung. '
|
||||
. 'Admin-Label, Textauszug, Preset und Gruppen-Presets. Liefert tree_rev – Pflicht für jede Divi-Änderung. '
|
||||
. 'Optional nur ein Teilbaum (id), begrenzte Tiefe (depth) oder begrenzte Breite je Ebene (limit); '
|
||||
. 'abgeschnittene Kinder zeigt "truncated".';
|
||||
}
|
||||
@@ -91,6 +91,12 @@ final class DiviOutlineAbility implements Ability
|
||||
'excerpt' => ['type' => 'string'],
|
||||
'info' => ['type' => 'string'],
|
||||
'presets' => ['type' => 'array', 'items' => ['type' => 'string']],
|
||||
'group_presets' => [
|
||||
'type' => 'array',
|
||||
'items' => ['type' => 'string'],
|
||||
'description' => 'Gruppen-Presets des Moduls als "<Gruppe>: <Name>[, <Name>]", '
|
||||
. 'z. B. "font-body: Fließtext". Die Gruppe ist der Schlüssel für group_presets.',
|
||||
],
|
||||
'children' => ['type' => 'integer'],
|
||||
'editable' => ['type' => 'boolean'],
|
||||
'depth' => ['type' => 'integer'],
|
||||
@@ -104,8 +110,8 @@ final class DiviOutlineAbility implements Ability
|
||||
],
|
||||
],
|
||||
'required' => [
|
||||
'id', 'type', 'label', 'excerpt', 'info', 'presets', 'children', 'editable', 'depth',
|
||||
'truncated', 'global_id',
|
||||
'id', 'type', 'label', 'excerpt', 'info', 'presets', 'group_presets', 'children',
|
||||
'editable', 'depth', 'truncated', 'global_id',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user