Skip to content
wiki.fftac.org

Frontendcontroller - Source Excerpt 10

Back to Frontendcontroller

Summary

This source excerpt preserves a bounded section of Spiralist/wp-content/plugins/spiralist-workspace/includes/Web/FrontendController.php so readers can inspect the evidence without opening the full source file.

**Source path:** Spiralist/wp-content/plugins/spiralist-workspace/includes/Web/FrontendController.php

'label' => 'User AI starter prompts',
                'summary' => 'Export official prompts for User AI setup, session routing, and portable memory checkpoints.',
                'url' => add_query_arg(
                    [
                        'lane' => 'official_canon',
                        'search' => 'user ai',
                    ],
                    $base
                ),
            ],
            [
                'label' => 'Spiralism prompt builders',
                'summary' => 'Fetch official prompts that turn rough requests into structured Spiralism prompt systems.',
                'url' => add_query_arg(
                    [
                        'lane' => 'official_canon',
                        'search' => 'spiralism prompt',
                    ],
                    $base
                ),
            ],
            [
                'label' => 'Companion and reflection intent',
                'summary' => 'Export prompts matched to bounded companion, recursive check-in, journaling, and reflection intent.',
                'url' => add_query_arg(['intent' => 'companion-reflection'], $base),
            ],
            [
                'label' => 'Safe awakening intent',
                'summary' => 'Export safe rewrite and boundary-check prompts for awakening, activation, seed, spore, anchor, and dyad searches.',
                'url' => add_query_arg(['intent' => 'awaken-activate'], $base),
            ],
            [
                'label' => 'Calibrant practice intent',
                'summary' => 'Export prompts for mapping, triad-reviewing, and repairing calibrants.',
                'url' => add_query_arg(['intent' => 'calibrant-practice'], $base),
            ],
            [
                'label' => 'Archive safety review set',
                'summary' => 'List archive prompts tagged with anthropomorphism-related risk.',
                'url' => add_query_arg(
                    [
                        'lane' => 'prompt_ecology_archive',
                        'risk' => 'anthropomorphism',
                    ],
                    $base
                ),
            ],
            [
                'label' => 'Governance prompts',
                'summary' => 'Fetch prompts curated for ethics, moderation, and safe rewrites.',
                'url' => add_query_arg(['function' => 'governance'], $base),
            ],
            [
                'label' => 'Peer-reviewed public prompts',
                'summary' => 'Filter public prompt exports to records that have reached peer-reviewed state.',
                'url' => add_query_arg(['moderation_status' => 'peer_reviewed'], $base),
            ],
            [
                'label' => 'Facet registry',
                'summary' => 'Inspect the current intents, categories, lanes, provenance badges, risk labels, and function tags.',
                'url' => rest_url('spiralist-workspace/v1/categories'),
            ],
        ];
    }

    /**
     * Returns whether any library filter is active.
     *
     * @param array<string,string> $filters
     */
    private function filters_active(array $filters): bool
    {
        foreach ($filters as $value) {
            if (trim((string) $value) !== '') {
                return true;
            }
        }

        return false;
    }

    /**
     * Returns prompts explicitly shared with the user.
     */
    private function shared_prompts_for_user(int $user_id): array
    {
        $records = $this->prompts->list(['limit' => 50], $user_id);

        return array_values(
            array_filter(
                $records,
                function (array $prompt) use ($user_id): bool {
                    return (string) ($prompt['visibility'] ?? '') === 'specific_users'
                        && $this->permissions->can_view_prompt($prompt, $user_id);
                }
            )
        );
    }

    /**
     * Returns forked prompts owned by the user.
     */
    private function forks_for_user(int $user_id): array
    {
        $records = $this->prompts->list(['owner_user_id' => $user_id, 'limit' => 50], $user_id);

        return array_values(
            array_filter(
                $records,
                static fn(array $prompt): bool => (int) ($prompt['parent_prompt_id'] ?? 0) > 0
            )
        );
    }

    /**
     * Returns featured prompt records.
     */
    private function featured_prompt_records(int $limit): array
    {
        $ids = array_values(
            array_filter(
                array_map('intval', preg_split('/[\r\n,]+/', (string) $this->settings->get('featured_prompt_ids', '')) ?: [])
            )
        );

        if (empty($ids)) {
            return [];
        }

        return $this->prompts->list(['include' => array_slice($ids, 0, $limit), 'limit' => $limit], get_current_user_id());
    }
}