Add AI Prompt management functionality within AI core
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3509235. -->
Reported by: [scott_euser](https://www.drupal.org/user/3267594)
Related to !480
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>There is no centralised prompt management. Discussed with @mandclu + @yautja_cetanu - have been exploring this here.</p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>Prompts are mostly </p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<ul>
<li>☑ Centralised prompt management area</li>
<li>☑ Prompt types to group prompts together</li>
<li>☑ AI Prompt custom element to make it easy to adopt </li>
<li>☑ Documentation + sample update hook to help existing prompts switch over if/when they'd like (sample via AI Content Suggestions sub-module)</li>
<li>☑ Test coverage for all of the above</li>
</ul>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>TBD from review, but at least:</p>
<ol>
<li>☑ Wait until <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/ai/-/work_items/3520049" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/ai/-/work_items/3520049</a></span> is merged</li>
<li>☑ Finish AiPromptElementTest::testAiPromptElementAccess()</li>
<li>☐ Ensure variable decided on for <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/ai/-/work_items/3525122" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/ai/-/work_items/3525122</a></span> is used here</li>
</ol>
<p>Follow-ups needed/suggested for:</p>
<ol>
<li>☐ custom autocomplete JS functionality (like @mentions type thing but not tied to CK Editor): <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/ai/-/work_items/3525122" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/ai/-/work_items/3525122</a></span></li>
<li>☐ @marcus_johansson's comment about supporting Twig, needs more info but maybe just works as ultimately this still provides same output as status quo of textarea</li>
<li>☐ @marcus_johansson's comment about making available for use in MCP. Again unsure if there is an issue here.</li>
<li>☐ Figure out why Functional JS tests don't run at all in 10.4 per comment #13</li>
<li>☐ Trim prompts in the table and e.g. add an expand/collapse to show all. @marcus_johansson flagged some AI Agent prompts are e.g. 2000+ words</li>
<li>☐ Add pagination within the element</li>
</ol>
<h3 id="how-to-test">How to test</h3>
<p>The merge request contains an upgrade for 2 textareas within /admin/config/ai/suggestions which is available when the AI Content Suggestions sub-module of the AI module is enabled. If already enabled, use the drush updb hook BUT remember since its not merged, there is no downgrade path, so backup first or you will have to re-add those prompts.</p>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>Prompt management centralised but still easy ability to create in place using AI Prompt custom element extending TableSelect.</p>
<h3 id="summary-api-changes">API changes</h3>
<p>N/A</p>
<h3 id="summary-data-model-changes">Data model changes</h3>
<p>Prompt entity + Prompt Type entity</p>
issue