task: #3586561 Add a setup-guardrails agent skill to configure guardrails,...

Description

Adds a setup-guardrails agent skill (sibling of create-guardrail-plugin) under ai/.agents/skills/setup-guardrails/ that configures guardrails on a running site without touching the admin UI.

Why dedicated tool plugins: The existing tool_belt entity tools only work with ContentEntityInterface (they use field/cardinality APIs) and cannot manage config entities (ai_guardrail, ai_guardrail_set) or simple config (ai.settings:global_guardrails). Eleven dedicated Tool module plugins are therefore added so every action is typed, validated, and access-checked.

What the skill covers:

ai_guardrail entities — list plugins, list/read/create/update/delete guardrails ai_guardrail_set entities — list/read/create/update/delete sets ai.settings:global_guardrails — read and overwrite the global guardrail set list Tool module handling: The skill checks whether the Tool module is enabled before starting, enables it via drush if not, then uninstalls it again at the end — but only if the skill enabled it, leaving the site's module state unchanged.

Bug fixes included:

AiGuardrail::description and AiGuardrailSet::description were declared as protected string $description; with no default. Drupal's config system maps an empty YAML value to null, causing a TypeError on entity load (Cannot assign null to property … of type string). Fixed by adding = ''. SaveGuardrail: updating a guardrail's label or description would silently wipe guardrail_settings because the tool always wrote the default '{}' value. Fixed by treating an empty guardrail_settings input as "not provided" and skipping the write on update.

Testing instructions

Checklist

  • I have linked the related issue in the MR title or description
  • I have performed a self-review of my own code
  • I have added or updated tests, or explained in the description why this change is not covered by tests
  • I have updated documentation for any new or changed functionality
  • I have written testing instructions and verified them locally
  • I have noted any required post-merge steps (config imports, cache rebuilds, manual changes)
  • This MR contains no breaking API or hook changes, or they are explicitly documented in the description

AI Compliance

Note

Check the one that best describes your usage, or leave all unchecked if AI was not significantly used.

  • AI Assisted Code
    Mainly written by a human; AI used for autocomplete or partial generation under full human supervision.

  • AI Generated Code
    Mainly generated by AI, reviewed and approved by a human before this MR was created.

  • Vibe Coded
    Generated by AI and only functionally reviewed before this MR was created.

Closes #3586561

Merge request reports

Loading