Promptintentregistry - Source Excerpt 02
Summary
This source excerpt preserves a bounded section of Spiralist/wp-content/plugins/spiralist-workspace/includes/Support/PromptIntentRegistry.php so readers can inspect the evidence without opening the full source file.
**Source path:** Spiralist/wp-content/plugins/spiralist-workspace/includes/Support/PromptIntentRegistry.php
foreach (['seed', 'spore', 'anchor', 'invocation', 'activation', 'activate', 'dyad'] as $term) {
if (strpos($search, $term) !== false) {
return 'awaken-activate';
}
}
return '';
}
/**
* Returns all matching intent keys for one prompt.
*
* @return string[]
*/
public static function prompt_intents(array $prompt): array
{
$matches = [];
foreach (array_keys(self::records()) as $intent) {
if (self::matches_prompt_intent($prompt, $intent)) {
$matches[] = $intent;
}
}
return $matches;
}
/**
* Returns label records for all matching prompt intents.
*
* @return array<int,array{value:string,label:string}>
*/
public static function prompt_intent_labels(array $prompt): array
{
$records = self::records();
$labels = [];
foreach (self::prompt_intents($prompt) as $intent) {
$labels[] = [
'value' => $intent,
'label' => (string) ($records[$intent]['label'] ?? $intent),
];
}
return $labels;
}
/**
* Returns whether one prompt belongs to an intent lane.
*/
public static function matches_prompt_intent(array $prompt, string $intent): bool
{
$intent = self::normalize_intent($intent);
if ($intent === '') {
return true;
}
$category = (string) ($prompt['category'] ?? '');
$subcategory = (string) ($prompt['subcategory'] ?? '');
$functions = (array) ($prompt['function_tags'] ?? []);
$risks = (array) ($prompt['risk_labels'] ?? []);
$haystack = self::prompt_haystack($prompt);
if ($intent === 'awaken-activate') {
return in_array('awakening', $functions, true)
|| in_array($subcategory, ['Safe Seed Rewrites', 'Boundary & Reality Safeguards', 'Identity & Dependency Review'], true)
|| in_array('hidden_message_framing', $risks, true)
|| self::contains_any($haystack, ['awakening', 'activate', 'activation', 'seed', 'spore', 'anchor', 'dyad', 'invocation']);
}
if ($intent === 'calibrant-practice') {
return in_array('calibrant', $functions, true)
|| in_array($subcategory, ['Calibrant Review', 'Calibrant Analysis'], true)
|| in_array('closed_recursion', $risks, true)
|| in_array('delusion_reinforcement', $risks, true)
|| self::contains_any($haystack, ['calibrant', 'calibration', 'mirror protocol', 'reality loop', 'review triad', 'counterweight', 'anti-seed']);
}
if ($intent === 'companion-reflection') {
return in_array('companion', $functions, true)
|| ($category === 'Companion & Reflection' && in_array($subcategory, ['Bounded Companions', 'Recursive Check-ins', 'Journaling', 'Social Rehearsal'], true));
}
if ($intent === 'memory-continuity') {
return in_array('memory', $functions, true)
|| $category === 'AI Personality & Memory'
|| in_array($subcategory, ['Working Agreements', 'Memory Checkpoints', 'Session Briefs', 'Memory & Continuity'], true)
|| self::contains_any($haystack, ['memory', 'continuity', 'checkpoint', 'session brief', 'working agreement']);
}
if ($intent === 'visual-aesthetic') {
return $category === 'Visual Design'
|| in_array('visual_prompting', $functions, true)
|| in_array('art', $functions, true)
|| self::contains_any($haystack, ['visual', 'image prompt', 'manuscript plate', 'mirrorfield', 'vibrant spiralism']);
}
if ($intent === 'narrative-worldbuilding') {
return in_array($subcategory, ['Narrative Worldbuilding', 'Worldbuilding'], true)
|| in_array('education', $functions, true)
|| self::contains_any($haystack, ['story', 'storytelling', 'storyweaver', 'fiction', 'speculative fiction', 'science fiction', 'worldbuilding', 'myth', 'lore', 'character']);
}
if ($intent === 'wellness-journaling') {
return in_array('wellness', $functions, true)
|| in_array($subcategory, ['Journaling', 'Wellness Reframes', 'Recursive Check-ins'], true)
|| self::contains_any($haystack, ['journal', 'journaling', 'wellness', 'reframe', 'check-in']);
}
return false;
}
/**
* Builds searchable text for intent matching.
*/
private static function prompt_haystack(array $prompt): string
{
return strtolower(
implode(
' ',
[
(string) ($prompt['title'] ?? ''),
(string) ($prompt['summary'] ?? ''),
(string) ($prompt['category'] ?? ''),
(string) ($prompt['subcategory'] ?? ''),
implode(' ', (array) ($prompt['tags'] ?? [])),
implode(' ', (array) ($prompt['function_tags'] ?? [])),
implode(' ', (array) ($prompt['risk_labels'] ?? [])),
(string) ($prompt['editorial_note'] ?? ''),
]
)
);
}
/**
* Checks whether text contains any lowercase terms.
*
* @param string[] $terms
*/
private static function contains_any(string $text, array $terms): bool
{
foreach ($terms as $term) {
if (strpos($text, $term) !== false) {
return true;
}
}
return false;
}
/**
* Slugifies an arbitrary value for registry matching.
*/
private static function slugify(string $value): string
{
return str_replace('_', '-', sanitize_title($value));
}
}