"""HTML views for the prompt library (#428).""" from __future__ import annotations import html from webui.prompt_library import PromptEntry, load_prompt_library def _escape(text: str) -> str: return html.escape(text, quote=True) def render_prompts_page() -> str: entries = load_prompt_library() cards: list[str] = [] for entry in entries: cards.append(_render_prompt_card(entry)) body = ( "
Short copy/paste task prompts derived from canonical workflows. " "Full policy remains in the cited workflow files — not duplicated here.
" f"{''.join(cards)}" f"{PROMPT_PAGE_SCRIPT}" ) from webui.layout import render_page return render_page(title="Prompts", body_html=body) def _render_prompt_card(entry: PromptEntry) -> str: hash_short = ( f"{_escape(entry.workflow_hash[:12])}"
if entry.workflow_hash
else "n/a"
)
task_mode = (
f"{_escape(entry.task_mode)}"
if entry.task_mode
else "n/a"
)
note = (
f''
if entry.source_note
else ""
)
prompt_id = f"prompt-{entry.slug}"
return (
f'{_escape(entry.prompt_text)}'
f'"
f"{note}"
"