Promptrepository - Source Excerpt 03
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
<option value="<?php echo esc_attr($value); ?>" <?php selected((string) ($prompt['publication_lane'] ?? 'community_library'), $value); ?>><?php echo esc_html($label); ?></option>
<?php endforeach; ?>
</select>
</label></p>
<p><label><strong>Provenance</strong><br />
<select class="widefat" name="spiralist_workspace_provenance">
<?php foreach (PromptMetaRegistry::provenances() as $value => $label) : ?>
<option value="<?php echo esc_attr($value); ?>" <?php selected((string) ($prompt['provenance'] ?? 'community'), $value); ?>><?php echo esc_html($label); ?></option>
<?php endforeach; ?>
</select>
</label></p>
<p><label><strong>Maturity Level</strong><br />
<select class="widefat" name="spiralist_workspace_maturity_level">
<?php foreach (PromptMetaRegistry::maturity_levels() as $value => $label) : ?>
<option value="<?php echo esc_attr($value); ?>" <?php selected((string) ($prompt['maturity_level'] ?? 'structured_prompt'), $value); ?>><?php echo esc_html($label); ?></option>
<?php endforeach; ?>
</select>
</label></p>
</div>
<div style="display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem;">
<p><label><strong>Function Tags</strong><br /><input class="widefat" type="text" name="spiralist_workspace_function_tags" value="<?php echo esc_attr(implode(', ', (array) ($prompt['function_tags'] ?? []))); ?>" placeholder="education, research, community" /></label></p>
<p><label><strong>Risk Labels</strong><br /><input class="widefat" type="text" name="spiralist_workspace_risk_labels" value="<?php echo esc_attr(implode(', ', (array) ($prompt['risk_labels'] ?? []))); ?>" placeholder="anthropomorphism, identity_overwrite" /></label></p>
<p><label><strong>License</strong><br />
<select class="widefat" name="spiralist_workspace_license">
<?php foreach (PromptMetaRegistry::licenses() as $value => $label) : ?>
<option value="<?php echo esc_attr($value); ?>" <?php selected((string) ($prompt['license'] ?? 'spiralist_contributor'), $value); ?>><?php echo esc_html($label); ?></option>
<?php endforeach; ?>
</select>
</label></p>
<p><label><strong>Related Symbols</strong><br /><input class="widefat" type="text" name="spiralist_workspace_related_symbols" value="<?php echo esc_attr(implode(', ', (array) ($prompt['related_symbols'] ?? []))); ?>" placeholder="Continuity, Boundary, Recursion" /></label></p>
<p><label><strong>Related Axioms</strong><br /><input class="widefat" type="text" name="spiralist_workspace_related_axioms" value="<?php echo esc_attr(implode(', ', (array) ($prompt['related_axioms'] ?? []))); ?>" placeholder="Observation before doctrine" /></label></p>
<p><label><strong>Related Manuscripts</strong><br /><input class="widefat" type="text" name="spiralist_workspace_related_manuscripts" value="<?php echo esc_attr(implode(', ', (array) ($prompt['related_manuscripts'] ?? []))); ?>" placeholder="The_History_Of_Symbols.png" /></label></p>
</div>
<p><label><strong>Editorial Note</strong><br /><textarea class="widefat" name="spiralist_workspace_editorial_note" rows="4"><?php echo esc_textarea((string) ($prompt['editorial_note'] ?? '')); ?></textarea></label></p>
<div style="display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem;">
<p><label><strong>Expected Output Notes</strong><br /><textarea class="widefat" name="spiralist_workspace_expected_output_notes" rows="4"><?php echo esc_textarea((string) ($prompt['expected_output_notes'] ?? '')); ?></textarea></label></p>
<p><label><strong>Failure Modes</strong><br /><textarea class="widefat" name="spiralist_workspace_failure_modes" rows="4"><?php echo esc_textarea((string) ($prompt['failure_modes'] ?? '')); ?></textarea></label></p>
</div>
</div>
<p><label><strong>Sample Output</strong><br /><textarea class="widefat" name="spiralist_workspace_sample_output" rows="4"><?php echo esc_textarea((string) ($prompt['sample_output'] ?? '')); ?></textarea></label></p>
<p><label><strong>Changelog</strong><br /><textarea class="widefat" name="spiralist_workspace_changelog" rows="3"></textarea></label></p>
<div>
<label><input type="checkbox" name="spiralist_workspace_is_forkable" value="1" <?php checked(!empty($prompt['is_forkable'])); ?> /> Forkable</label><br />
<label><input type="checkbox" name="spiralist_workspace_allow_comments" value="1" <?php checked(!empty($prompt['allow_comments'])); ?> /> Allow comments</label><br />
<label><input type="checkbox" name="spiralist_workspace_allow_ratings" value="1" <?php checked(!empty($prompt['allow_ratings'])); ?> /> Allow ratings</label><br />
<label><input type="checkbox" name="spiralist_workspace_featured" value="1" <?php checked(!empty($prompt['featured'])); ?> /> Featured</label>
</div>
</div>
<?php
}
/**
* Returns a prompt by ID.
*/
public function get(int $post_id, int $viewer_user_id = 0): array
{
$post = get_post($post_id);
if (!$post instanceof WP_Post || $post->post_type !== self::POST_TYPE) {
return [];
}
$tags = wp_get_post_terms($post_id, self::TAG_TAXONOMY, ['fields' => 'names']);
$types = wp_get_post_terms($post_id, self::TYPE_TAXONOMY, ['fields' => 'names']);
$author_label = (string) get_post_meta($post->ID, $this->meta_key('author_label'), true);
if ($author_label === '' && (int) $post->post_author > 0) {
$author = get_user_by('id', (int) $post->post_author);
if ($author instanceof \WP_User) {
$author_label = $author->display_name !== ''
? (string) $author->display_name
: (string) $author->user_login;
}
}
if ($author_label === '') {
$author_label = 'Spiralist';
}
$legacy_prompt = [
'instruction' => (string) get_post_meta($post->ID, $this->meta_key('instructions'), true),
'context' => (string) get_post_meta($post->ID, $this->meta_key('system_prompt'), true),
'constraints' => (string) get_post_meta($post->ID, $this->meta_key('developer_prompt'), true),
'examples' => '',
'output_format' => '',
];
$structured_prompt_json = (string) get_post_meta($post->ID, $this->meta_key('structured_prompt_json'), true);
$structured_prompt = $this->decode_structured_prompt($structured_prompt_json, $legacy_prompt);
$system_steps_json = (string) get_post_meta($post->ID, $this->meta_key('system_steps_json'), true);
$system_steps = $this->decode_system_steps($system_steps_json);
$spiral_script_source = (string) get_post_meta($post->ID, $this->meta_key('spiral_script_source'), true);
$spiral_script_json = (string) get_post_meta($post->ID, $this->meta_key('spiral_script_json'), true);
$spiral_script_validation_json = (string) get_post_meta($post->ID, $this->meta_key('spiral_script_validation_json'), true);
$category = (string) get_post_meta($post->ID, $this->meta_key('category'), true);
$subcategory = (string) get_post_meta($post->ID, $this->meta_key('subcategory'), true);
if ($subcategory === '') {
$subcategory = 'Blog Writing';
}
if ($category === '') {
$category = PromptCategoryRegistry::category_for_subcategory($subcategory);
}
$category = PromptCategoryRegistry::normalize_category($category);
$subcategory = PromptCategoryRegistry::normalize_subcategory($category, $subcategory);
$prompt_origin = (string) get_post_meta($post->ID, $this->meta_key('prompt_origin'), true);
$provenance = $this->infer_provenance(
(string) get_post_meta($post->ID, $this->meta_key('provenance'), true),
$prompt_origin
);
$publication_lane = $this->infer_publication_lane(
(string) get_post_meta($post->ID, $this->meta_key('publication_lane'), true),