Views Agent development assistant (submodule)
Design notes for modules/views_agent_dev_assistant/. For install
instructions and what it creates, see that module's own README; this
covers the why behind how it's built.
Why a submodule
The assistant needs Gin, gin_toolbar, and ai_chatbot - none of which
ai_agents_views itself has any reason to depend on. Keeping it as its
own module means enabling it is one drush en, backed almost entirely by
Drupal's own module dependency resolution, and everyone who just wants
the Views Agent tools isn't forced to pull in a theme and a chat UI.
Why it's hidden (hidden: true)
The Extend page (/admin/modules) runs every module's hook_requirements()
for the whole batch before installing anything, and silently drops any
module that fails it - along with anything depending on it. Since this
module's own requirements check (below) can't force-block installation
the way that page implies, hiding it from that page steers everyone
toward drush instead, where the real behavior (a graceful degrade, not a
block) is what actually happens.
How the Gin prerequisite is handled
A module's dependencies can only list other modules, not themes, so
Gin can't be declared as a dependency the way gin_toolbar is.
views_agent_dev_assistant.install implements hook_requirements()
instead, modeled directly on gin_toolbar_requirements(): it reports an
install-blocking error if Gin isn't installed.
That check is advisory, not enforced by ModuleInstaller::install()
itself - it protects the Extend page and gives drush a skippable
confirmation prompt ("Install requirements failed. Do you wish to
continue?"), but installing this module directly, or via a
confirmed-through drush command, without Gin present does not fail.
It degrades instead:
- The agent and assistant config still get created - their dependencies are real module dependencies, already guaranteed active.
- The chatbot block - which ships in
config/optional, notconfig/install, specifically because it targets the Gin theme - gets silently skipped instead of created broken.config/optional's own dependency check is what does this: Drupal never enforces the Gin requirement before installing this module, soconfig/optionalis what actually keeps a block targeting a missing theme from being created.
Creating the block retroactively
If Gin is installed after this module already was, the skipped block
doesn't stay missing forever. src/Hook/ViewsAgentDevAssistantHooks.php
implements #[Hook('themes_installed')], which calls
ConfigInstaller::installOptionalConfig(NULL, ['theme' => 'gin'])
whenever a theme is installed and Gin is among them - the same
mechanism Drupal's own module installer uses internally to pick up
optional config whose dependencies have just been satisfied.
Clean uninstall
All three shipped config objects (ai_agents.ai_agent.views_assistant,
ai_assistant_api.ai_assistant.views_assistant,
block.block.views_assistant_chatbot) declare an enforced dependency on
views_agent_dev_assistant, so uninstalling the module removes them
again through Drupal's own config-dependency system - no custom
uninstall code needed.