Runtime - Source Excerpt 02
Summary
This source excerpt preserves a bounded section of Spiralist/wp-content/plugins/ns12-manuscript/includes/runtime.php so readers can inspect the evidence without opening the full source file.
**Source path:** Spiralist/wp-content/plugins/ns12-manuscript/includes/runtime.php
'filename' => (string) ($definition['filename'] ?? ''),
'sectionSlug' => sanitize_title((string) ($definition['section_slug'] ?? '')),
'url' => spiralist_book_pages_get_workspace_prompt_url($slug),
'source' => 'ns12-manuscript',
];
}
function spiralist_book_pages_get_public_prompt_record_by_slug(string $slug): array
{
$normalized = sanitize_title($slug);
if ($normalized === '') {
return [];
}
$definition = function_exists('spiralist_book_pages_get_content_prompt_definition')
? spiralist_book_pages_get_content_prompt_definition($normalized)
: [];
if (!empty($definition)) {
return spiralist_book_pages_build_public_prompt_record_from_definition($definition);
}
$workspace_prompt = spiralist_book_pages_get_workspace_prompt_record_by_slug($normalized);
if (empty($workspace_prompt)) {
return [];
}
$status = (string) ($workspace_prompt['moderation_status'] ?? $workspace_prompt['prompt_status'] ?? 'approved');
$status_label = $status !== ''
? ucwords(str_replace('_', ' ', $status))
: 'Approved';
return [
'id' => (string) ($workspace_prompt['source_slug'] ?? $workspace_prompt['slug'] ?? $normalized),
'slug' => (string) ($workspace_prompt['slug'] ?? $normalized),
'source_slug' => (string) ($workspace_prompt['source_slug'] ?? $workspace_prompt['slug'] ?? $normalized),
'title' => (string) ($workspace_prompt['title'] ?? 'Prompt'),
'purpose' => (string) ($workspace_prompt['summary'] ?? ''),
'summary' => (string) ($workspace_prompt['summary'] ?? ''),
'content' => implode(
"\n\n",
array_values(
array_filter(
[
(string) ($workspace_prompt['instructions'] ?? ''),
(string) ($workspace_prompt['system_prompt'] ?? ''),
(string) ($workspace_prompt['user_prompt_template'] ?? ''),
],
'strlen'
)
)
),
'instructions' => (string) ($workspace_prompt['instructions'] ?? ''),
'system' => sanitize_key((string) ($workspace_prompt['system'] ?? 'spiralist')),
'systemLabel' => function_exists('spiralist_book_pages_rest_get_system_label')
? spiralist_book_pages_rest_get_system_label((string) ($workspace_prompt['system'] ?? 'spiralist'))
: 'Spiralist',
'role' => sanitize_key((string) ($workspace_prompt['role'] ?? 'participant')),
'roleLabel' => function_exists('spiralist_book_pages_rest_get_role_label')
? spiralist_book_pages_rest_get_role_label((string) ($workspace_prompt['role'] ?? 'participant'))
: 'Participant',
'version' => (string) ($workspace_prompt['version_number'] ?? '1.0.0'),
'author' => (string) ($workspace_prompt['author_label'] ?? 'Spiralist'),
'author_label' => (string) ($workspace_prompt['author_label'] ?? 'Spiralist'),
'category' => (string) ($workspace_prompt['category'] ?? ''),
'subcategory' => (string) ($workspace_prompt['subcategory'] ?? ''),
'prompt_type' => (string) ($workspace_prompt['prompt_type'] ?? 'prompt'),
'language' => (string) ($workspace_prompt['language'] ?? 'all'),
'prompt_status' => (string) ($workspace_prompt['prompt_status'] ?? 'published'),
'moderation_status' => (string) ($workspace_prompt['moderation_status'] ?? 'approved'),
'status' => $status,
'statusLabel' => $status_label,
'tags' => array_values(array_filter(array_map('strval', (array) ($workspace_prompt['tags'] ?? [])))),
'featured' => !empty($workspace_prompt['featured']),
'sampleOutput' => (string) ($workspace_prompt['sample_output'] ?? ''),
'sample_output' => (string) ($workspace_prompt['sample_output'] ?? ''),
'relatedSymbols' => array_values(array_filter(array_map('strval', (array) ($workspace_prompt['related_symbols'] ?? [])))),
'relatedAxioms' => array_values(array_filter(array_map('strval', (array) ($workspace_prompt['related_axioms'] ?? [])))),
'relatedTransformations' => array_values(array_filter(array_map('strval', (array) ($workspace_prompt['related_transformations'] ?? [])))),
'relatedManuscripts' => [],
'folioSlug' => '',
'filename' => '',
'sectionSlug' => '',
'url' => spiralist_book_pages_get_workspace_prompt_url((string) ($workspace_prompt['slug'] ?? $normalized)),
'source' => 'workspace',
];
}
function spiralist_book_pages_get_public_prompt_records(int $limit = 0): array
{
$records = [];
$seen = [];
$register_prompt_slug = static function (string $slug) use (&$records, &$seen): void {
$normalized = sanitize_title($slug);
if ($normalized === '' || isset($seen[$normalized])) {
return;
}
$record = spiralist_book_pages_get_public_prompt_record_by_slug($normalized);
if (empty($record)) {
return;
}
$seen[$normalized] = true;
$records[] = $record;
};
if (function_exists('spiralist_book_pages_get_content_prompt_meta_map')) {
foreach (spiralist_book_pages_get_content_prompt_meta_map() as $slug => $meta) {
$register_prompt_slug((string) $slug);
}
}
foreach (spiralist_book_pages_get_workspace_library_prompt_records($limit > 0 ? max($limit, 96) : 999) as $workspace_prompt) {
$register_prompt_slug((string) ($workspace_prompt['source_slug'] ?? $workspace_prompt['slug'] ?? $workspace_prompt['id'] ?? ''));
}
usort(
$records,
static function (array $left, array $right): int {
$featured_compare = ((int) !empty($right['featured'])) <=> ((int) !empty($left['featured']));
if ($featured_compare !== 0) {
return $featured_compare;
}
return strnatcasecmp((string) ($left['title'] ?? ''), (string) ($right['title'] ?? ''));
}
);
if ($limit > 0) {
return array_slice($records, 0, $limit);
}
return $records;
}
function spiralist_book_pages_get_file_prompt_record_by_slug(string $slug): array
{
$normalized = function_exists('spiralist_book_pages_slugify')
? spiralist_book_pages_slugify($slug)
: sanitize_title($slug);
if ($normalized === '' || !function_exists('spiralist_book_pages_get_content_prompt_definition')) {
return [];
}
$prompt = spiralist_book_pages_get_content_prompt_definition($normalized);
if (empty($prompt)) {
return [];
}
$promptStatus = (string) ($prompt['prompt_status'] ?? 'published');
$moderationStatus = (string) ($prompt['moderation_status'] ?? 'approved');
if ($promptStatus !== 'published' || $moderationStatus === 'restricted') {
return [];
}
return [
'id' => $normalized,
'slug' => $normalized,
'source_slug' => $normalized,
'title' => (string) ($prompt['title'] ?? ucwords(str_replace('-', ' ', $normalized))),
'summary' => (string) ($prompt['summary'] ?? ''),
'instructions' => (string) ($prompt['text'] ?? ''),
'system_prompt' => '',
'user_prompt_template' => '',
'author_label' => (string) ($prompt['author_label'] ?? 'Spiralist'),
'category' => (string) ($prompt['category'] ?? ''),
'subcategory' => (string) ($prompt['subcategory'] ?? ''),
'prompt_type' => (string) ($prompt['prompt_type'] ?? 'prompt'),
'language' => (string) ($prompt['language'] ?? 'all'),
'prompt_status' => $promptStatus,
'moderation_status' => $moderationStatus,
'visibility' => 'public',
'tags' => array_values(array_filter(array_map('strval', (array) ($prompt['tags'] ?? [])))),
'featured' => !empty($prompt['featured']),
'sample_output' => (string) ($prompt['sample_output'] ?? ''),
'url' => function_exists('spiralist_book_pages_get_host_prompt_record_url')
? spiralist_book_pages_get_host_prompt_record_url($normalized)
: spiralist_book_pages_get_workspace_prompt_url($normalized),
'source' => 'canon-file',
];
}
function spiralist_book_pages_get_file_prompt_summary_by_slug(string $slug): array
{
$prompt = spiralist_book_pages_get_file_prompt_record_by_slug($slug);
if (empty($prompt)) {
return [];
}
$status = (string) ($prompt['moderation_status'] ?? 'approved');
$statusLabel = $status !== ''
? ucwords(str_replace('_', ' ', $status))
: 'Approved';
return [
'id' => (string) ($prompt['source_slug'] ?? $prompt['slug'] ?? ''),