report-viewer
Latest: v0.1.0
- Added report-viewer guidance for publishing Markdown, HTML dashboards, Excalidraw boards, and Reveal.js presentations through the local REST API.
- Documented backend health checks and automatic startup, plus publishing from inline content or a file.
- Added a browser-comment feedback loop for updating reports in place and resolving comments after successful publishing.
- Added guidance for interactive quizzes and flashcards, including templates, result storage, and comment-widget caveats.
- Documented Excalidraw autosave and object comments, and clarified that Quarto and
.qmdfiles are unsupported.
Report-Viewer (Skill)
Container-Variant: Direct REST API calls, no MCP server required. The viewer runs at
http://localhost:8765from the OpenClaw container. The skill checks the backend on every invocation and starts it automatically if needed.
Prerequisites
- The skill checks the backend health on every invocation.
- If the backend is not running, the skill starts it automatically via
start.sh. - If the backend is running, it is reused as-is.
- No external URLs are ever invented — always use the link returned by
POST /api/publish.
0. Pre-flight: ensure backend is up
# Check health
HEALTH=$(curl -s -m3 http://localhost:8765/api/health 2>/dev/null || echo "")
if echo "$HEALTH" | grep -q '"status": "ok"'; then
echo "Backend already running"
else
echo "Backend not running — starting it..."
cd /config/clawd/skills/report-viewer
nohup ./start.sh >/tmp/rv.log 2>&1 &
sleep 2
# Verify
HEALTH=$(curl -s -m3 http://localhost:8765/api/health 2>/dev/null || echo "")
if echo "$HEALTH" | grep -q '"status": "ok"'; then
echo "Backend started successfully"
else
echo "ERROR: Backend failed to start. Check /tmp/rv.log"
exit 1
fi
fi
1. Format selection
| Format | Use for |
|---|---|
md | Reports, analyses, architecture docs, tables, Mermaid blocks, KaTeX ($...$ / $$...$$) |
html | Interactive dashboards (Chart.js, Plotly, ECharts), complex web layouts |
html (Quiz/Flashcard) | Interactive quizzes & flashcards — take references/quiz-template.html, replace placeholders, publish as html |
excalidraw | A real .excalidraw board (JSON as content or source_path) — includes mindmaps |
| revealjs | Slide presentations from Markdown (slides separated by ---). Plugins: highlight, zoom (Ctrl+Scroll), search (Ctrl+F) |
Not supported (container): Quarto/.qmd, <stem>_files/. Desktop-only.
2. Publish a report
Inline content:
curl -s -X POST http://localhost:8765/api/publish \
-H "Content-Type: application/json" \
-d '{"title":"<short title>","format":"md|html|excalidraw|revealjs","content":"<raw content>"}'
From a file on disk:
curl -s -X POST http://localhost:8765/api/publish \
-H "Content-Type: application/json" \
-d '{"title":"<short title>","format":"md|html|excalidraw|revealjs","source_path":"/path/to/file"}'
Response contains filename, url, created (true on first publish, false on overwrite).
Give the URL to the user exactly as returned. Never construct URLs yourself.
3. Feedback loop (browser comments → source)
-
List comments for a report:
bash curl -s "http://localhost:8765/api/comments?filename=<filename>"Returns an array of comments:
id,author,text,quote,created, optionallyresolved, plus contextual anchors:card_ref(int, flashcard — index of the card) andexcal_id(string, Excalidraw — the element id the comment is tied to). -
Update the source:
- With
source_path: patch the original file (e.g. the brain vault.md) so the working copy stays in sync. - Without
source_path: rewrite thecontentstring.
- With
-
In-place overwrite (same URL stays):
bash curl -s -X POST http://localhost:8765/api/publish \ -H "Content-Type: application/json" \ -d '{"title":"<title>","format":"md|html|excalidraw|revealjs","source_path":"<same path>","filename":"<existing filename>"}'or with
contentinstead ofsource_path. -
Mark comments resolved (only AFTER publish succeeded):
bash curl -s -X POST http://localhost:8765/api/comments/<comment_id>/resolve -
Tell the user: what was patched, that they should press F5.
4. Hard rules (never break)
- Iterations always overwrite the same
filename— no new timestamped file (unless the user explicitly asks for a new version). - Resolve comments only after
publish_reportsucceeded. - Never invent URLs — only the link returned by the publish call.
- When
source_pathwas used, keep that file patched (working copy ↔ viewer sync). - If the backend cannot be started → refuse to run, tell the user to check
/tmp/rv.log. - No Quarto, no
.qmd— those are desktop-only.
4.5 Quiz and flashcards (interactive HTML, working)
Both formats are interactive HTML pages served by the viewer. Each one is a single self-contained file in reports/.
Working examples (verified, HTTP 200):
- Quiz, all four question types:
http://localhost:8765/view/quiz-beispiel-alle-formate-v1.html - Flashcards (flip card, right/wrong):
http://localhost:8765/view/flashcards-llm-governance-eu-ai-act.html
Quiz question types (array QUESTIONS in references/quiz-template.html):
type | Fields | Evaluation |
|---|---|---|
mc | q, options, correct (index), why | click an option |
tf | q, correct (true/false), why | click true or false |
cloze | q (with __ as gap), answer, why | typed input, compared case-insensitively |
text | q, answer (alternatives separated by ;), why | typed input, matches if any alternative fits |
Flashcards — two templates:
references/flashcard-template.html(standalone,CARDS = [{q, a}]): flip card, self-rate right/wrong. Poststype:"flashcard"withscore/totalon completion.- The flashcard engine inside
references/quiz-template.html(SM-2 spaced repetition, 1–5 rating,FLASHCARDSarray): poststype:"flashcard"with per-cardcards+avg_rating.
Use the standalone template for simple right/wrong decks; use the quiz template's flashcard mode when you want SM-2 intervals.
Creating a new page: copy the working file as a base, replace the question or card array and the title, then publish it with POST /api/publish, format: "html", content = full HTML.
Comment widget caveat: the comment engine treats elements with the class .card as commentable and intercepts their clicks. The flashcard uses .fc-card for this reason. Do not name interactive elements .card.
Result storage: the quiz posts its result to /api/quiz/result on completion, shown at /quiz-results. Both flashcard templates also post results (type:"flashcard") on completion — the standalone one sends score/total, the quiz-template one sends per-card cards + avg_rating. All appear under the Flashcard section of /quiz-results.
4.6 Excalidraw (autosave + object comments)
- Autosave: edits on an Excalidraw board persist automatically. The client debounces (800 ms) and POSTs the scene to
POST /api/reports/<filename>/excalidraw; on load the viewer fetchesGET /api/reports/<filename>/excalidrawand restores the saved scene if present (else the original from the report). The scene is stored in a sidecar<filename>.excalidraw.jsonnext to the report; deleting the report also deletes the sidecar. - ⚠️ Re-publishing a board (desired overhaul): the sidecar takes precedence over the report's original on load. If you re-publish a board with a new/changed scene (e.g. to apply feedback, re-theme, or restructure), you must delete the sidecar first — otherwise the viewer keeps showing the user's old autosaved scene and your new original never appears. Delete it with
rm ~/.report_viewer/reports/<filename>.html.excalidraw.json(ordelon Windows) before/after the re-publish. This is a "reset to the freshly published board". - Object comments: the 💬 comment panel on an Excalidraw page has an object dropdown. Picking an object tags the comment with
excal_id(the element id), shown in the list as· Objekt: <label>. Text elements are labeled by their content; other shapes by type + index.
4.7 Theming (change the look on a user's behalf)
The UI is themed via CSS custom properties in the :root block of static/css/style.css
(14 variables: --bg, --bg-card, --bg-hover, --border, --text, --text-muted,
--accent, --accent-hover, --radius, --font-sans, --font-mono, --success,
--error, --warning). To re-theme: pick new values, edit only those values in the
:root block, sync the file (no restart; browser hard-reload), verify legibility.
Full variable map + light-theme worked example + caveats (frozen reports / inline
styles / Chart.js / Excalidraw wrapper keep hardcoded colors) → references/theming.md.
4.8 HTML Dashboard (own chrome, not a template)
format: "html" is served raw — no wrapper is injected. The published file
MUST be a complete standalone HTML document that carries its own chrome:
Required (in this order):
<html lang="de" data-theme="light">← enables the viewer's CSS variables<link rel="stylesheet" href="/static/css/style.css"><body class="report-body"><header>with<a href="/">← Übersicht</a>+<h1>{title}</h1>(copy the exact markup from the Excalidraw wrapper inapp.py)- All colors via
var(--…)— never hardcode hex for theme-relevant colors (bg, card, border, text, accent). Chart.js palettes: read variables withgetComputedStyle(document.documentElement).getPropertyValue("--…")at runtime.
Not required:
- No
<style>block for layout colors —style.cssalready defines.card,.badge, header, toolbar, etc. Only add CSS for custom components (KPI cards, filter buttons) that don't exist instyle.css.
5. Deactivation / fallback
If the backend is unreachable and cannot be started:
- Do not execute the skill.
- Tell the user: "Report-Viewer backend not reachable at localhost:8765 — skill deactivation. Check
/tmp/rv.logor runcd /config/clawd/skills/report-viewer && ./start.shmanually." - Never produce fake URLs.
6. Smoke tests (definition of done)
- Pre-flight: backend already running → "already running" message.
- Pre-flight: backend not running → starts via
start.sh→ "started successfully". -
curl -X POST .../api/publishwith a smallmdpayload → response contains aurl→ paste in chat, confirm. - Add a comment in the browser →
GET /api/comments?filename=...shows it → patch source →POST /api/publish(samefilename) →POST /api/comments/<id>/resolve→ F5 → comment gone. - Graceful degradation:
start.shfails → skill refuses and tells user.
7. References
- Viewer project (skill dir):
/config/clawd/skills/report-viewer/ - Similar skill:
skills/session-closeout/SKILL.md - Quiz template:
references/quiz-template.html - Quiz results dashboard:
/quiz-results(live, auto-aggregiert) - Theming guide:
references/theming.md(CSS-variable palette, light-theme example, caveats)
