feat: add web UI prompt library from canonical workflows (#428)

Surface short copy/paste operator prompts derived from canonical workflow
files with workflow path and SHA-256 citations. Adds /prompts, /prompts/{id},
and /api/prompts with one-click copy.

Closes #428
This commit is contained in:
2026-07-07 14:53:16 -04:00
parent 6670c72e65
commit f845864889
4 changed files with 127 additions and 87 deletions
+25 -18
View File
@@ -4,6 +4,7 @@ from __future__ import annotations
import html
from webui.layout import render_page
from webui.prompt_library import PromptEntry, load_prompt_library
@@ -11,23 +12,6 @@ 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 = (
"<h2>Prompt library</h2>"
"<p>Short copy/paste task prompts derived from canonical workflows. "
"Full policy remains in the cited workflow files — not duplicated here.</p>"
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"<code>{_escape(entry.workflow_hash[:12])}</code>"
@@ -77,4 +61,27 @@ document.querySelectorAll('.copy-btn').forEach((btn) => {
});
});
</script>
"""
"""
def render_prompts_page() -> str:
entries = load_prompt_library()
cards = "".join(_render_prompt_card(entry) for entry in entries)
body = (
"<h2>Prompt library</h2>"
"<p>Short copy/paste task prompts derived from canonical workflows. "
"Full policy remains in the cited workflow files — not duplicated here.</p>"
f"{cards}"
"<p><a href=\"/api/prompts\">JSON API</a></p>"
f"{PROMPT_PAGE_SCRIPT}"
)
return render_page(title="Prompts", body_html=body)
def render_prompt_detail(entry: PromptEntry) -> str:
body = (
f"<p><a href=\"/prompts\">← All prompts</a></p>"
f"{_render_prompt_card(entry)}"
f"{PROMPT_PAGE_SCRIPT}"
)
return render_page(title=entry.label, body_html=body)