Skip to content
wiki.fftac.org

Promptrepository - Source Excerpt 04

Back to Promptrepository

Summary

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

**Source path:** Spiralist/wp-content/plugins/spiralist-workspace/includes/Domain/PromptRepository.php

$provenance,
            $prompt_origin
        );
        $maturity_level = $this->infer_maturity_level(
            (string) get_post_meta($post->ID, $this->meta_key('maturity_level'), true),
            $structured_prompt,
            $system_steps
        );
        $moderation_status = PromptMetaRegistry::normalize_moderation_status(
            (string) get_post_meta($post->ID, $this->meta_key('moderation_status'), true)
        );
        $license = PromptMetaRegistry::normalize_license((string) get_post_meta($post->ID, $this->meta_key('license'), true));
        $risk_labels = PromptMetaRegistry::normalize_risk_labels(
            $this->decode_string_list((string) get_post_meta($post->ID, $this->meta_key('risk_labels_json'), true))
        );
        $function_tags = PromptMetaRegistry::normalize_function_tags(
            $this->decode_string_list((string) get_post_meta($post->ID, $this->meta_key('function_tags_json'), true))
        );
        $related_symbols = PromptMetaRegistry::normalize_freeform_list(
            $this->decode_string_list((string) get_post_meta($post->ID, $this->meta_key('related_symbols_json'), true))
        );
        $related_axioms = PromptMetaRegistry::normalize_freeform_list(
            $this->decode_string_list((string) get_post_meta($post->ID, $this->meta_key('related_axioms_json'), true))
        );
        $related_manuscripts = PromptMetaRegistry::normalize_freeform_list(
            $this->decode_string_list((string) get_post_meta($post->ID, $this->meta_key('related_manuscripts_json'), true))
        );
        $tag_values = is_array($tags) ? array_values(array_filter($tags, 'is_string')) : [];
        $intent_source = [
            'title' => (string) $post->post_title,
            'summary' => (string) $post->post_excerpt,
            'category' => $category,
            'subcategory' => $subcategory,
            'tags' => $tag_values,
            'risk_labels' => $risk_labels,
            'function_tags' => $function_tags,
            'editorial_note' => (string) get_post_meta($post->ID, $this->meta_key('editorial_note'), true),
        ];

        return [
            'id' => (int) $post->ID,
            'title' => (string) $post->post_title,
            'slug' => (string) $post->post_name,
            'summary' => (string) $post->post_excerpt,
            'category' => $category,
            'subcategory' => $subcategory,
            'structured_prompt' => $structured_prompt,
            'structured_prompt_json' => wp_json_encode($structured_prompt, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE),
            'instructions' => (string) get_post_meta($post->ID, $this->meta_key('instructions'), true),
            'system_prompt' => (string) get_post_meta($post->ID, $this->meta_key('system_prompt'), true),
            'developer_prompt' => (string) get_post_meta($post->ID, $this->meta_key('developer_prompt'), true),
            'user_prompt_template' => (string) get_post_meta($post->ID, $this->meta_key('user_prompt_template'), true),
            'system_steps' => $system_steps,
            'system_steps_json' => wp_json_encode($system_steps, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE),
            'spiral_script_source' => $spiral_script_source,
            'spiral_script' => $this->decode_assoc_json($spiral_script_json),
            'spiral_script_json' => $spiral_script_json,
            'spiral_script_validation' => $this->decode_assoc_json($spiral_script_validation_json),
            'spiral_script_validation_json' => $spiral_script_validation_json,
            'spiral_script_status' => (string) get_post_meta($post->ID, $this->meta_key('spiral_script_status'), true),
            'model' => (string) get_post_meta($post->ID, $this->meta_key('model'), true),
            'provider' => (string) get_post_meta($post->ID, $this->meta_key('provider'), true),
            'credential_preference' => (string) get_post_meta($post->ID, $this->meta_key('credential_preference'), true),
            'temperature' => (float) get_post_meta($post->ID, $this->meta_key('temperature'), true),
            'max_output_tokens' => (int) get_post_meta($post->ID, $this->meta_key('max_output_tokens'), true),
            'tool_settings_json' => (string) get_post_meta($post->ID, $this->meta_key('tool_settings_json'), true),
            'visibility' => (string) get_post_meta($post->ID, $this->meta_key('visibility'), true),
            'owner_user_id' => (int) $post->post_author,
            'author_label' => $author_label,
            'created_utc' => get_post_time('c', true, $post),
            'updated_utc' => get_post_modified_time('c', true, $post),
            'published_utc' => (string) get_post_meta($post->ID, $this->meta_key('published_utc'), true),
            'is_forkable' => get_post_meta($post->ID, $this->meta_key('is_forkable'), true) === '1',
            'allow_comments' => get_post_meta($post->ID, $this->meta_key('allow_comments'), true) === '1',
            'allow_ratings' => get_post_meta($post->ID, $this->meta_key('allow_ratings'), true) === '1',
            'tags' => $tag_values,
            'canonical_status' => (string) get_post_meta($post->ID, $this->meta_key('canonical_status'), true),
            'version_number' => max(1, (int) get_post_meta($post->ID, $this->meta_key('version_number'), true)),
            'parent_prompt_id' => (int) get_post_meta($post->ID, $this->meta_key('parent_prompt_id'), true),
            'prompt_type' => !empty($types[0]) ? (string) $types[0] : (string) get_post_meta($post->ID, $this->meta_key('prompt_type'), true),
            'language' => (string) get_post_meta($post->ID, $this->meta_key('language'), true),
            'prompt_status' => (string) get_post_meta($post->ID, $this->meta_key('prompt_status'), true),
            'moderation_status' => $moderation_status,
            'moderation_status_label' => PromptMetaRegistry::moderation_status_label($moderation_status),
            'publication_lane' => $publication_lane,
            'publication_lane_label' => PromptMetaRegistry::publication_lane_label($publication_lane),
            'provenance' => $provenance,
            'provenance_label' => PromptMetaRegistry::provenance_label($provenance),
            'risk_labels' => $risk_labels,
            'risk_label_labels' => PromptMetaRegistry::risk_label_labels($risk_labels),
            'function_tags' => $function_tags,
            'function_tag_labels' => PromptMetaRegistry::function_tag_labels($function_tags),
            'intent_tags' => PromptIntentRegistry::prompt_intents($intent_source),
            'intent_tag_labels' => PromptIntentRegistry::prompt_intent_labels($intent_source),
            'maturity_level' => $maturity_level,
            'maturity_level_label' => PromptMetaRegistry::maturity_level_label($maturity_level),
            'license' => $license,
            'license_label' => PromptMetaRegistry::license_label($license),
            'editorial_note' => (string) get_post_meta($post->ID, $this->meta_key('editorial_note'), true),
            'expected_output_notes' => (string) get_post_meta($post->ID, $this->meta_key('expected_output_notes'), true),
            'failure_modes' => (string) get_post_meta($post->ID, $this->meta_key('failure_modes'), true),
            'related_symbols' => $related_symbols,
            'related_axioms' => $related_axioms,
            'related_manuscripts' => $related_manuscripts,
            'sample_output' => (string) get_post_meta($post->ID, $this->meta_key('sample_output'), true),
            'featured' => get_post_meta($post->ID, $this->meta_key('featured'), true) === '1',
            'soft_deleted_at' => (string) get_post_meta($post->ID, $this->meta_key('soft_deleted_at'), true),
            'public_execution_enabled' => get_post_meta($post->ID, $this->meta_key('public_execution_enabled'), true) === '1',
            'prompt_origin' => $prompt_origin,
            'source_manifest' => (string) get_post_meta($post->ID, $this->meta_key('source_manifest'), true),
            'source_slug' => (string) get_post_meta($post->ID, $this->meta_key('source_slug'), true),
            'source_version' => (string) get_post_meta($post->ID, $this->meta_key('source_version'), true),
            'source_hash' => (string) get_post_meta($post->ID, $this->meta_key('source_hash'), true),
            'source_path' => (string) get_post_meta($post->ID, $this->meta_key('source_path'), true),
            'post_status' => (string) $post->post_status,
            'post_content' => (string) $post->post_content,
            'favorite' => $viewer_user_id > 0 ? $this->favorites->is_favorite((int) $post->ID, $viewer_user_id) : false,
        ];
    }

    /**
     * Finds a prompt by slug.
     */
    public function find_by_slug(string $slug, int $viewer_user_id = 0): array
    {