gerodp/hermes-productivity-skills / reports/weekly-report
weekly-report
VerifiedOne weekly report combining Super Productivity time per project/task (with week-over-week deltas), Obsidian notes of the week grouped by folder (with key bullet points), emails sent this week, calendar events, git commits per repo, Claude Code sessions per project, and Umami page visits vs last week — with a skimmable TL;DR summary at the top.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 19.8 KB |
| scripts/render_html.py | script | 34.8 KB |
| scripts/render_markdown.py | script | 13.8 KB |
| scripts/test_render_html.py | script | 17.4 KB |
| scripts/test_render_markdown.py | script | 4.9 KB |
| scripts/test_weekly_report.py | script | 32.0 KB |
| scripts/weekly_report.py | script | 51.2 KB |
scripts/render_html.py
View on GitHub#!/usr/bin/env python3
"""render_html — turn a weekly-report JSON bundle into a self-contained HTML page.
Consumes the JSON bundle produced by ``weekly_report.py gather`` (the documented
contract — see the weekly-report SKILL.md) and renders a single, dependency-free
HTML file with a highlights card band and one **collapsible section per part**,
laid out **3 per row** (full width) and **expanded by default**:
Projects & time · Calendar · Git activity
Notes · Emails sent · Visits
A highlights band tops the page (hours, a projects-by-time pie, meetings with the
longest ones, top repos by commits, site visits).
Each section is a native ``<details>``/``<summary>`` element (no JavaScript
required to expand/collapse; a tiny expand-all / collapse-all control is layered
on top). Every ``{"error": …}`` section degrades to an "unavailable" note, just
like the Markdown render path — one missing source never breaks the page. The
whole thing is inlined (CSS in a ``<style>`` tag), so the output is a single
portable ``.html`` you can email, open, or archive.
Usage:
weekly_report.py gather --period this-week | render_html.py > report.html
render_html.py bundle.json --output report.html --title "Week 26"
Python standard library only.
"""
from __future__ import annotations
import argparse
import html
import json
import math
import sys
from datetime import datetime
# --------------------------------------------------------------------------- #
# Small formatting helpers
# --------------------------------------------------------------------------- #
def esc(s):
"""HTML-escape any value (None → '')."""
return html.escape("" if s is None else str(s), quote=True)
def fmt_hours(h):
try:
return f"{float(h):.1f}h"
except (TypeError, ValueError):
return "0.0h"
def fmt_usd(x):
"""A compact USD string: '$12.34' under $100, '$1,234' above."""
try:
v = float(x or 0)
except (TypeError, ValueError):
return "$0"
return f"${v:.2f}" if v < 100 else f"${v:,.0f}"
def section_error(data):
"""Return the error string if `data` is an ``{"error": …}`` section, else None."""
if isinstance(data, dict) and "error" in data:
return data["error"]
return None
def _as_int(v):
"""Coerce a bundle value used in an unescaped badge to an int — `details()`
passes badges through raw (they can carry delta-badge HTML), so a tampered
or hand-edited bundle must not be able to smuggle markup via a count."""
try:
return int(v)
except (TypeError, ValueError):
return 0
def _pct_badge(cur, prev):
"""A coloured ▲/▼ **percentage** delta badge (for hours week-over-week)."""
try:
cur, prev = float(cur or 0), float(prev or 0)
except (TypeError, ValueError):
return ""
if prev == 0:
return '<span class="delta up">▲new</span>' if cur else ""
pct = 100.0 * (cur - prev) / prev
cls, arrow = ("up", "▲") if pct > 0 else ("down", "▼") if pct < 0 else ("flat", "—")
return f'<span class="delta {cls}">{arrow}{abs(pct):.0f}%</span>'
def _delta_badge(cur, prev):
"""A coloured ▲/▼ delta badge comparing `cur` to `prev`."""
try:
cur, prev = float(cur or 0), float(prev or 0)
except (TypeError, ValueError):
return ""
diff = cur - prev
if prev == 0:
cls, arrow, txt = ("up", "▲", "new") if cur else ("flat", "—", "")
elif diff > 0:
cls, arrow, txt = "up", "▲", f"{abs(diff):,.0f}"
elif diff < 0:
cls, arrow, txt = "down", "▼", f"{abs(diff):,.0f}"
else:
cls, arrow, txt = "flat", "—", ""
return f'<span class="delta {cls}">{arrow}{esc(txt)}</span>'
def _fmt_mins(mins):
"""Minutes → 'Hh MMm' (or 'Mm' under an hour)."""
mins = int(round(mins or 0))
h, m = divmod(mins, 60)
return f"{h}h {m:02d}m" if h else f"{m}m"
def _fmt_secs(secs):
"""Seconds → 'Mm SSs' (or 'Ss' under a minute)."""
secs = int(round(secs or 0))
m, s = divmod(secs, 60)
return f"{m}m {s:02d}s" if m else f"{s}s"
def event_minutes(ev):
"""Duration of a calendar event in minutes (0 if unknown/negative).
Prefers the full ISO ``start``/``end`` timestamps; falls back to the
``start_local``/``end_local`` ``HH:MM`` strings for same-day events."""
s, e = ev.get("start"), ev.get("end")
if s and e:
try:
d = (datetime.fromisoformat(e) - datetime.fromisoformat(s)).total_seconds() / 60.0
if d >= 0:
return d
except (ValueError, TypeError):
pass
a, b = ev.get("start_local"), ev.get("end_local")
try:
if a and b and ":" in a and ":" in b:
ah, am = (int(x) for x in a.split(":")[:2])
bh, bm = (int(x) for x in b.split(":")[:2])
d = (bh * 60 + bm) - (ah * 60 + am)
if d >= 0:
return d
except (ValueError, TypeError):
pass
return 0
# Slice colours for the projects pie (cycled).
PIE_COLORS = ["#6ea8fe", "#8b9dff", "#34d399", "#fbbf24", "#f87171",
"#c084fc", "#22d3ee", "#f472b6"]
def pie_svg(pairs, size=132):
"""Inline-SVG donut-free pie from [(label, value), …]; returns (svg, legend).
Pure geometry (no JS/deps). A single ~100% slice is drawn as a full circle to
avoid a degenerate arc."""
total = sum(v for _, v in pairs) or 1
r = size / 2.0
cx = cy = r
paths, legend, ang = [], [], -90.0
for i, (label, val) in enumerate(pairs):
frac = (val or 0) / total
color = PIE_COLORS[i % len(PIE_COLORS)]
if frac >= 0.999:
paths.append(f'<circle cx="{cx}" cy="{cy}" r="{r}" fill="{color}"/>')
elif frac > 0:
a0 = math.radians(ang)
ang += frac * 360.0
a1 = math.radians(ang)
x0, y0 = cx + r * math.cos(a0), cy + r * math.sin(a0)
x1, y1 = cx + r * math.cos(a1), cy + r * math.sin(a1)
large = 1 if frac > 0.5 else 0
paths.append(f'<path d="M{cx:.1f},{cy:.1f} L{x0:.1f},{y0:.1f} '
f'A{r:.1f},{r:.1f} 0 {large} 1 {x1:.1f},{y1:.1f} Z" fill="{color}"/>')
legend.append(f'<li><span class="sw" style="background:{color}"></span>'
f'<span class="lname">{esc(label)}</span>'
f'<span class="lval">{fmt_hours(val)} · {100.0 * frac:.0f}%</span></li>')
svg = (f'<svg width="{size}" height="{size}" viewBox="0 0 {size} {size}" '
f'role="img">{"".join(paths)}</svg>')
return svg, f'<ul class="legend">{"".join(legend)}</ul>'
# --------------------------------------------------------------------------- #
# Building blocks
# --------------------------------------------------------------------------- #
def details(title, body_html, *, subtitle="", badge="", open_=None, level="section"):
"""One collapsible block. `level` is a CSS class ('section' or 'note').
Top-level sections default to **expanded**; nested ('note') blocks default to
collapsed. Pass `open_` explicitly to override."""
if open_ is None:
open_ = (level == "section")
sub = f'<span class="sub">{esc(subtitle)}</span>' if subtitle else ""
bdg = f'<span class="badge">{badge}</span>' if badge else ""
return (
f'<details class="{level}"{" open" if open_ else ""}>'
f'<summary><span class="s-title">{esc(title)}</span>{bdg}{sub}</summary>'
f'<div class="body">{body_html}</div>'
f'</details>'
)
def _unavailable(msg):
return f'<p class="unavailable">unavailable: {esc(msg)}</p>'
def _empty(msg):
return f'<p class="empty">{esc(msg)}</p>'
def _table(headers, rows, *, foot=None):
head = "".join(f"<th>{esc(h)}</th>" for h in headers)
body = "".join(
"<tr>" + "".join(f"<td>{c}</td>" for c in r) + "</tr>" for r in rows
)
foot_html = ""
if foot:
foot_html = "<tfoot><tr>" + "".join(f"<td>{c}</td>" for c in foot) + "</tr></tfoot>"
return f"<table><thead><tr>{head}</tr></thead><tbody>{body}</tbody>{foot_html}</table>"
# --------------------------------------------------------------------------- #
# Sections (each consumes its slice of the bundle → a <details> block)
# --------------------------------------------------------------------------- #
def render_projects(data):
err = section_error(data)
if err:
return details("Projects & time", _unavailable(err))
projects = (data or {}).get("projects", []) or []
tasks = (data or {}).get("tasks", []) or []
if not projects:
return details("Projects & time", _empty("No time tracked this week."))
total = sum(float(p.get("hours", 0) or 0) for p in projects)
# One expandable row per project (name + hours), expanding to its tasks —
# the project list appears exactly once (no separate overview table).
blocks = []
for p in projects:
name = p.get("project", "?")
ptasks = sorted((t for t in tasks if t.get("project") == name),
key=lambda t: -float(t.get("hours", 0) or 0))
items = "".join(
f'<li><span class="hrs">{fmt_hours(t.get("hours", 0))}</span>'
f'{esc(t.get("title", "(untitled)"))}</li>'
for t in ptasks
) or '<li class="empty">no itemised tasks</li>'
badge = fmt_hours(p.get("hours", 0))
if "hours_prev" in p: # week-over-week delta vs the prior period
badge += " " + _pct_badge(p.get("hours", 0), p.get("hours_prev", 0))
blocks.append(details(name, f'<ul class="tasks">{items}</ul>',
badge=badge, level="note"))
blocks.append(f'<div class="total-row"><span>TOTAL</span>'
f'<span class="hrs">{fmt_hours(total)}</span></div>')
return details("Projects & time", "".join(blocks),
badge=fmt_hours(total), open_=True)
def render_notes(data):
err = section_error(data)
if err:
return details("Obsidian Notes", _unavailable(err))
notes = (data or {}).get("notes", []) or []
if not notes:
return details("Obsidian Notes", _empty("No notes modified this week."))
# Cluster by top-level folder (group) so related notes read together; a
# group header is emitted whenever the group changes.
def _group(n):
return n.get("group") or "(root)"
ordered = sorted(notes, key=lambda n: (_group(n) == "(root)", _group(n).lower()))
blocks, cur_group = [], None
for n in ordered:
g = _group(n)
if g != cur_group:
cur_group = g
blocks.append(f'<div class="note-group">{esc(g)}</div>')
body = (n.get("body") or "").strip()
if body:
inner = f'<div class="note-body">{esc(body)}</div>'
else:
inner = _empty("The note body is empty.")
if n.get("truncated"):
inner += '<p class="hint">body truncated — raise --note-chars for more.</p>'
sub = f"mod {n.get('modified', '?')}"
blocks.append(details(n.get("name") or n.get("rel") or "(note)", inner,
subtitle=sub, level="note"))
if (data or {}).get("dropped"):
blocks.append(f'<p class="hint">+{esc(data["dropped"])} more note(s) not '
f'shown — raise --max-notes.</p>')
if (data or {}).get("excluded"):
blocks.append(f'<p class="hint">{esc(data["excluded"])} note(s) excluded '
f'by OBSIDIAN_EXCLUDE.</p>')
return details("Obsidian Notes", "".join(blocks), badge=str(len(notes)))
def render_emails(data):
err = section_error(data)
if err:
return details("Emails sent", _unavailable(err))
emails = (data or {}).get("emails", []) or []
if not emails:
return details("Emails sent", _empty("No emails sent this week."))
rows = []
for e in emails:
recips = e.get("to") or []
subj = e.get("subject") or "(no subject)"
# First recipient shown inline with the subject; hover shows all of them.
rcpt = ""
if recips:
rcpt = (f' <span class="rcpt" title="{esc(", ".join(recips))}">'
f'({esc(recips[0])})</span>')
snip = e.get("snippet") or ""
snip_html = f'<div class="snippet">{esc(snip)}</div>' if snip else ""
rows.append([esc(e.get("date", "")), f'{esc(subj)}{rcpt}{snip_html}'])
tbl = _table(["Date", "Subject"], rows)
if (data or {}).get("possibly_truncated"):
tbl += '<p class="hint">list may be incomplete — raise --max-emails.</p>'
return details("Emails sent", tbl, badge=str(len(emails)))
def render_calendar(data):
err = section_error(data)
if err:
return details("Calendar", _unavailable(err))
events = (data or {}).get("events", []) or []
if not events:
return details("Calendar", _empty("No events this week."))
rows = [[esc(ev.get("day", "")), esc(ev.get("summary", "(no title)"))]
for ev in events]
body = _table(["Day", "Event"], rows)
if (data or {}).get("excluded"):
body += (f'<p class="hint">{esc(data["excluded"])} personal event(s) '
f'excluded by CALENDAR_EXCLUDE.</p>')
return details("Calendar", body, badge=str(len(events)))
def render_visits(data):
err = section_error(data)
if err:
return details("Visits vs last week", _unavailable(err))
sites = (data or {}).get("sites", []) or []
if not sites:
return details("Visits vs last week", _empty("No visit data available."))
rows, tv, tp = [], 0, 0
for s in sites:
v, pv = s.get("visitors", 0) or 0, s.get("pageviews", 0) or 0
tv += v
tp += pv
dur = s.get("avg_duration")
dur_cell = "—" if dur is None else (
f'{_fmt_secs(dur)} {_delta_badge(dur, s.get("avg_duration_prev", 0))}')
bounce = s.get("bounce_pct")
sid = s.get("site_id")
name_cell = esc(s.get("name", "?"))
if sid:
name_cell += f' <span class="sid" title="Umami site id">{esc(sid)}</span>'
rows.append([
name_cell,
f'{v:,} {_delta_badge(v, s.get("visitors_prev", 0))}',
f'{s.get("visits", 0):,} {_delta_badge(s.get("visits", 0), s.get("visits_prev", 0))}',
f'{pv:,} {_delta_badge(pv, s.get("pageviews_prev", 0))}',
"—" if bounce is None else f'{float(bounce):.1f}%',
dur_cell,
])
foot = ["<strong>TOTAL</strong>", f"<strong>{tv:,}</strong>", "",
f"<strong>{tp:,}</strong>", "", ""]
return details("Visits vs last week",
_table(["Site", "Visitors", "Visits", "Pageviews",
"Bounce", "Avg. visit"], rows, foot=foot))
def render_git(data):
"""Commits section — renders the git-report bundle shape if present.
Forward-looking: the git-report skill emits ``{repos:[{repo,count,commits:[…],
insertions?,deletions?}], total}``. Rendered only when the bundle carries a
``git`` (or ``commits``) key, so it's a no-op until that source is wired in.
"""
err = section_error(data)
if err:
return details("Git activity", _unavailable(err))
repos = (data or {}).get("repos", []) or []
total = _as_int((data or {}).get(
"total", sum(_as_int(r.get("count", 0)) for r in repos)))
if not repos:
return details("Git activity", _empty("No commits this week."))
blocks = []
for r in repos:
items = "".join(
f'<li><span class="hash">{esc(c.get("short", ""))}</span>'
f'<span class="cdate">{esc(c.get("date", ""))}</span>'
f'{esc(c.get("subject", ""))}</li>'
for c in (r.get("commits") or [])
)
churn = ""
if "insertions" in r or "deletions" in r:
churn = f'+{r.get("insertions", 0)}/-{r.get("deletions", 0)}'
blocks.append(details(r.get("repo", "?"), f'<ul class="commits">{items}</ul>',
subtitle=churn, badge=str(_as_int(r.get("count", 0))),
level="note"))
return details("Git activity", "".join(blocks), badge=str(total))
def render_sessions(data):
"""Claude Code sessions section — renders the claude-sessions bundle shape.
Forward-looking: the claude-sessions skill (via the orchestrator's
``gather_sessions``) emits ``{total_sessions, total_cost_usd,
projects:[{project, sessions, cost_usd, entries:[{title, when, duration,
prompts, cost_usd, grade}]}]}``. Rendered only when the bundle carries a
``sessions`` key, so it's a no-op for older bundles. One collapsible block per
project (badge = session count, subtitle = API-equivalent cost), expanding to
that project's sessions."""
err = section_error(data)
if err:
return details("Claude Code sessions", _unavailable(err))
projects = (data or {}).get("projects", []) or []
total = _as_int((data or {}).get(
"total_sessions", sum(_as_int(p.get("sessions", 0)) for p in projects)))
if not projects:
return details("Claude Code sessions",
_empty("No Claude Code sessions this week."))
blocks = []
for p in projects:
items = "".join(
f'<li><span class="cdate">{esc(e.get("when", ""))}</span>'
f'<span class="grade">{esc(e.get("grade") or "–")}</span>'
f'<span class="stitle">{esc(e.get("title") or "(untitled)")}</span>'
f'<span class="scost">{esc(fmt_usd(e.get("cost_usd")))}</span></li>'
for e in (p.get("entries") or [])
)
blocks.append(details(p.get("project", "?"),
f'<ul class="sessions-list">{items}</ul>',
subtitle=fmt_usd(p.get("cost_usd", 0)),
badge=str(_as_int(p.get("sessions", 0))), level="note"))
sub = f"{fmt_usd((data or {}).get('total_cost_usd', 0))} API-eq"
return details("Claude Code sessions", "".join(blocks),
subtitle=sub, badge=str(total))
# --------------------------------------------------------------------------- #
# Highlights (top-of-page summary cards)
# --------------------------------------------------------------------------- #
def _stat_card(title, value, unit="", sub=""):
unit_html = f'<span class="unit">{esc(unit)}</span>' if unit else ""
sub_html = f'<div class="stat-sub">{esc(sub)}</div>' if sub else ""
return (f'<div class="card"><div class="card-h">{esc(title)}</div>'
f'<div class="stat">{esc(value)}{unit_html}</div>{sub_html}</div>')
def _list_card(title, pairs, *, ranked=True, span2=False, empty="no data"):
"""A card whose body is a compact key→value list. `pairs` is [(k, v), …]."""
if pairs:
tag = "ol" if ranked else "ul"
items = "".join(
f'<li>{"<span class=rank>" + str(i) + "</span>" if ranked else ""}'
f'<span class="k">{esc(k)}</span><span class="v">{esc(v)}</span></li>'
for i, (k, v) in enumerate(pairs, 1)
)
body = f'<{tag} class="mini">{items}</{tag}>'
else:
body = f'<div class="empty">{esc(empty)}</div>'
cls = "card span2" if span2 else "card"
return f'<div class="{cls}"><div class="card-h">{esc(title)}</div>{body}</div>'
def _top_pairs(items, key_field, val_field, val_fmt, n=5):
rows = sorted(items, key=lambda x: -float(x.get(val_field, 0) or 0))[:n]
return [(r.get(key_field, "?"), val_fmt(r.get(val_field, 0))) for r in rows]
def _meetings_card(count, total_min, top):
"""Meetings stat card: count + total time, then the 3 longest meetings."""
side = (f'<span class="side">· {esc(_fmt_mins(total_min))} total</span>'
if total_min else "")
lst = "".join(
f'<li><span class="k">{esc(name)}</span>'
f'<span class="mdur">{esc(dur)}</span></li>' for name, dur in top)
body = f'<ul class="mini">{lst}</ul>' if lst else ""
return (f'<div class="card"><div class="card-h">Meetings</div>'
f'<div class="stat">{count}{side}</div>{body}</div>')
def _pie_pairs(plist, n=6):
"""Top-n projects by hours as (name, hours); the rest folded into 'Other'."""
ordered = sorted(plist, key=lambda p: -float(p.get("hours", 0) or 0))
pairs = [(p.get("project", "?"), float(p.get("hours", 0) or 0)) for p in ordered]
if len(pairs) > n:
other = sum(v for _, v in pairs[n:])
pairs = pairs[:n] + ([("Other", other)] if other > 0 else [])
return pairs
def _pie_card(title, pairs):
"""A highlights card holding a pie chart + legend (spans 2 columns)."""
if not pairs:
return _list_card(title, [], span2=True, empty="no time tracked")
svg, legend = pie_svg(pairs)
body = f'<div class="pie-wrap">{svg}{legend}</div>'
return (f'<div class="card pie span2"><div class="card-h">{esc(title)}</div>'
f'{body}</div>')
def render_highlights(bundle):
"""The top summary band: total hours, top projects, top repos, meetings, visits."""
projects = bundle.get("projects", {}) or {}
calendar = bundle.get("calendar", {}) or {}
visits = bundle.get("visits", {}) or {}
git = bundle.get("git", bundle.get("commits")) or {}
cards = []
# 1) Total hours worked
if section_error(projects):
cards.append(_stat_card("Hours worked", "—", sub="projects unavailable"))
else:
plist = projects.get("projects", []) or []
total = sum(float(p.get("hours", 0) or 0) for p in plist)
cards.append(_stat_card("Hours worked", f"{total:.1f}", unit="h",
sub=f"across {len(plist)} project(s)"))
# 4) Meetings: count + total time, plus the 3 most time-consuming
if section_error(calendar):
cards.append(_stat_card("Meetings", "—", sub="calendar unavailable"))
else:
events = calendar.get("events", []) or []
meetings = [e for e in events if not e.get("all_day")]
durations = sorted(((event_minutes(m), m) for m in meetings),
key=lambda t: -t[0])
total_min = sum(d for d, _ in durations)
top = [(m.get("summary", "(no title)"), _fmt_mins(d))
for d, m in durations[:3] if d > 0]
cards.append(_meetings_card(len(meetings), total_min, top))
# 2) Projects by time — pie chart (top slices + "Other")
if section_error(projects):
cards.append(_pie_card("Projects by time", []))
else:
cards.append(_pie_card("Projects by time",
_pie_pairs(projects.get("projects", []) or [])))
# 3) Top 5 repos by commits
if section_error(git):
cards.append(_list_card("Top repos by commits", [], empty="commits unavailable"))
else:
repos = git.get("repos", []) or []
pairs = _top_pairs(repos, "repo", "count", lambda v: str(int(v or 0)))
cards.append(_list_card("Top repos by commits", pairs,
empty="no commit data"))
# 5) Visits per site
if section_error(visits):
cards.append(_list_card("Site visits", [], span2=True, ranked=False,
empty="visits unavailable"))
else:
sites = visits.get("sites", []) or []
pairs = [(s.get("name", "?"), f'{int(s.get("visitors", 0) or 0):,}')
for s in sites]
cards.append(_list_card("Site visits (visitors)", pairs, span2=True,
ranked=False, empty="no visit data"))
# 6) Claude Code sessions — only when the source is wired into the bundle.
sessions = bundle.get("sessions")
if sessions is not None:
if section_error(sessions):
cards.append(_stat_card("Claude sessions", "—",
sub="sessions unavailable"))
else:
sprojects = sessions.get("projects", []) or []
total = sessions.get("total_sessions",
sum(p.get("sessions", 0) for p in sprojects))
cost = sessions.get("total_cost_usd", 0)
sub = f"{len(sprojects)} project(s)" + (
f" · {fmt_usd(cost)} API-eq" if cost else "")
cards.append(_stat_card("Claude sessions", str(total), sub=sub))
return f'<section class="highlights">{"".join(cards)}</section>'
# --------------------------------------------------------------------------- #
# Page assembly
# --------------------------------------------------------------------------- #
STYLE = """
:root{--bg:#0a1730;--bg2:#0d1f3d;--card:#122544;--card2:#0f2039;--ink:#e8eefb;
--mut:#93a6c8;--line:#22385c;--accent:#6ea8fe;--accent2:#8b9dff;
--up:#34d399;--down:#f87171;--chip:#1c3157}
*{box-sizing:border-box}
body{margin:0;background:linear-gradient(180deg,#0a1730 0%,#0a1428 100%);
background-attachment:fixed;color:var(--ink);
font:15px/1.55 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
.wrap{max-width:none;margin:0;padding:30px 28px 64px}
header.rep{margin-bottom:20px}
header.rep h1{margin:0 0 4px;font-size:27px;letter-spacing:-.01em;color:#fff}
header.rep .range{color:var(--mut);font-size:14px}
header.rep .tldr{margin-top:8px;color:var(--ink);font-size:14.5px;font-weight:600;
background:var(--card);border:1px solid var(--line);border-radius:9px;padding:8px 13px;display:inline-block}
.controls{margin:16px 0 22px;display:flex;gap:8px}
.controls button{border:1px solid var(--line);background:var(--card);color:var(--ink);
border-radius:8px;padding:6px 12px;font-size:13px;cursor:pointer}
.controls button:hover{border-color:var(--accent);color:var(--accent)}
/* Highlights ------------------------------------------------------------- */
.highlights{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));
gap:14px;margin:0 0 26px}
.card{background:linear-gradient(180deg,var(--card) 0%,var(--card2) 100%);
border:1px solid var(--line);border-radius:14px;padding:15px 16px;
box-shadow:0 4px 18px rgba(2,8,23,.35)}
.card .card-h{color:var(--mut);font-size:11.5px;font-weight:700;text-transform:uppercase;
letter-spacing:.06em;margin-bottom:10px}
.card .stat{font-size:34px;font-weight:800;color:#fff;letter-spacing:-.02em;
font-variant-numeric:tabular-nums;line-height:1}
.card .stat .unit{font-size:16px;font-weight:600;color:var(--accent);margin-left:3px}
.card .stat-sub{color:var(--mut);font-size:12.5px;margin-top:8px}
.card.span2{grid-column:span 2}
ol.mini,ul.mini{margin:0;padding:0;list-style:none}
ol.mini li,ul.mini li{display:flex;align-items:baseline;gap:8px;padding:5px 0;
border-bottom:1px solid rgba(255,255,255,.05);font-size:13.5px}
ol.mini li:last-child,ul.mini li:last-child{border-bottom:none}
.mini .rank{color:var(--mut);font-size:11px;min-width:16px;font-variant-numeric:tabular-nums}
.mini .k{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.mini .v{color:var(--accent);font-weight:700;font-variant-numeric:tabular-nums}
/* Collapsible sections — 3 per row, full width -------------------------- */
.sections{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));
gap:16px;align-items:start}
@media (max-width:1100px){.sections{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media (max-width:720px){.sections{grid-template-columns:1fr}}
details.section{background:var(--card);border:1px solid var(--line);border-radius:12px;
margin:0;overflow:hidden;box-shadow:0 2px 10px rgba(2,8,23,.30);min-width:0}
details.section>.body{overflow-x:auto}
details.section>summary{padding:16px 18px;font-weight:600;font-size:17px;color:#fff}
details.note{border:1px solid var(--line);border-radius:9px;margin:10px 0;background:var(--card2)}
details.note>summary{padding:10px 12px;font-weight:600;font-size:14px}
summary{cursor:pointer;list-style:none;display:flex;align-items:center;gap:10px;user-select:none}
summary::-webkit-details-marker{display:none}
summary::before{content:"▸";color:var(--accent);font-size:12px;transition:transform .15s;flex:none}
details[open]>summary::before{transform:rotate(90deg)}
.s-title{flex:1}
.badge{background:var(--chip);color:var(--accent);border-radius:20px;padding:1px 10px;
font-size:12px;font-weight:600}
.sub{color:var(--mut);font-weight:400;font-size:12.5px}
.body{padding:2px 18px 18px}
details.note .body{padding:2px 12px 12px}
table{width:100%;border-collapse:collapse;margin:10px 0;font-size:14px}
th,td{text-align:left;padding:7px 10px;border-bottom:1px solid var(--line);vertical-align:top}
th{color:var(--mut);font-weight:600;font-size:12.5px;text-transform:uppercase;letter-spacing:.03em}
tfoot td{border-top:2px solid var(--line);border-bottom:none;padding-top:9px}
td:nth-child(n+2),th:nth-child(n+2){text-align:right}
table th:nth-child(1),table td:nth-child(1){text-align:left}
ul.tasks,ul.commits,ul.sessions-list{margin:6px 0;padding-left:2px;list-style:none}
ul.tasks li,ul.commits li,ul.sessions-list li{padding:4px 0;border-bottom:1px solid rgba(255,255,255,.05)}
ul.tasks li:last-child,ul.commits li:last-child,ul.sessions-list li:last-child{border-bottom:none}
ul.sessions-list li{display:flex;align-items:baseline;gap:8px}
.grade{display:inline-block;min-width:18px;text-align:center;color:var(--accent);font-weight:700;font-size:12.5px}
.stitle{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.scost{color:var(--accent);font-weight:600;font-variant-numeric:tabular-nums}
.hrs{display:inline-block;min-width:52px;color:var(--accent);font-weight:600;font-variant-numeric:tabular-nums}
.hash{display:inline-block;min-width:66px;color:var(--mut);font-family:ui-monospace,Menlo,monospace;font-size:12.5px}
.cdate{display:inline-block;min-width:96px;color:var(--mut);font-size:12.5px}
.note-body{white-space:pre-wrap;background:#0b1c36;border:1px solid var(--line);
border-radius:8px;padding:12px 14px;font-size:13.5px;color:#cdd8ef;max-height:520px;overflow:auto}
.snippet{color:var(--mut);font-size:12.5px;margin-top:2px}
.rcpt{color:var(--mut);font-weight:400}
.sid{color:var(--mut);font-family:ui-monospace,Menlo,monospace;font-size:11.5px;margin-left:6px}
.note-group{color:var(--accent);font-size:11.5px;font-weight:700;text-transform:uppercase;
letter-spacing:.05em;margin:12px 0 4px}
.delta{font-size:12px;font-weight:600}
.delta.up{color:var(--up)}.delta.down{color:var(--down)}.delta.flat{color:var(--mut)}
.unavailable{color:#fde68a;background:rgba(180,120,20,.14);border:1px solid #5c4a1e;
border-radius:8px;padding:8px 12px;font-size:13.5px;margin:8px 0}
.empty{color:var(--mut);font-style:italic;margin:8px 0}
.hint{color:var(--mut);font-size:12.5px;margin:8px 0 0}
.errors{margin-top:8px;color:var(--mut);font-size:13px}
.errors code{background:#132745;border-radius:4px;padding:1px 5px}
/* pie chart card + legend */
.card.pie .pie-wrap{display:flex;gap:16px;align-items:center;flex-wrap:wrap}
.card.pie svg{flex:none}
.legend{list-style:none;margin:0;padding:0;font-size:12.5px;flex:1;min-width:150px}
.legend li{display:flex;align-items:center;gap:8px;padding:3px 0}
.legend .sw{width:11px;height:11px;border-radius:3px;flex:none}
.legend .lname{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.legend .lval{color:var(--mut);font-variant-numeric:tabular-nums}
.stat .side{font-size:15px;font-weight:600;color:var(--accent);margin-left:8px}
.mdur{color:var(--accent);font-weight:700;font-variant-numeric:tabular-nums}
.total-row{display:flex;justify-content:space-between;align-items:baseline;
padding:9px 4px 2px;border-top:2px solid var(--line);margin-top:8px;font-weight:700}
""".strip()
SCRIPT = """
(function(){
function all(op){document.querySelectorAll('details.section').forEach(d=>d.open=op);}
var e=document.getElementById('exp'),c=document.getElementById('col');
if(e)e.onclick=function(){all(true)};
if(c)c.onclick=function(){all(false)};
})();
""".strip()
def build_html(bundle, *, title=None):
rng = (bundle or {}).get("range", {}) or {}
start, end = rng.get("start", "?"), rng.get("end", "?")
heading = title or "Weekly Report"
label = rng.get("label")
range_line = f"{start} → {end}" + (f" · {label}" if label else "")
summary = (bundle.get("summary") or {}).get("line")
tldr_html = f'<div class="tldr">{esc(summary)}</div>' if summary else ""
# 3-per-row grid, laid out to read:
# Projects & time | Calendar | Git activity
# Notes | Emails sent | Visits
# (git slots into column 3 of row 1; when absent, the rest simply reflow.)
sections = [render_projects(bundle.get("projects", {})),
render_calendar(bundle.get("calendar", {}))]
git = bundle.get("git", bundle.get("commits"))
if git is not None:
sections.append(render_git(git))
if bundle.get("sessions") is not None:
sections.append(render_sessions(bundle.get("sessions", {})))
sections += [render_notes(bundle.get("notes", {})),
render_emails(bundle.get("emails", {})),
render_visits(bundle.get("visits", {}))]
errors = bundle.get("errors") or []
err_html = ""
if errors:
items = " ".join(f"<code>{esc(e)}</code>" for e in errors)
err_html = f'<div class="errors">Skipped sources: {items}</div>'
return f"""<!DOCTYPE html>
<html lang="en"><head><meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{esc(heading)} — {esc(start)} to {esc(end)}</title>
<style>{STYLE}</style></head>
<body><div class="wrap">
<header class="rep"><h1>{esc(heading)}</h1><div class="range">{esc(range_line)}</div>{tldr_html}</header>
{render_highlights(bundle)}
<div class="controls"><button id="exp">Expand all</button><button id="col">Collapse all</button></div>
<div class="sections">{''.join(sections)}</div>
{err_html}
</div><script>{SCRIPT}</script></body></html>"""
# --------------------------------------------------------------------------- #
# CLI
# --------------------------------------------------------------------------- #
def main(argv=None):
p = argparse.ArgumentParser(
prog="render_html",
description="Render a weekly-report JSON bundle into a self-contained HTML page.")
p.add_argument("json_file", nargs="?", default="-",
help="path to the JSON bundle, or '-' for stdin (default)")
p.add_argument("--output", "-o", help="write HTML here (default: stdout)")
p.add_argument("--title", help="report heading (default 'Weekly Report')")
args = p.parse_args(argv)
try:
if args.json_file == "-":
bundle = json.load(sys.stdin)
else:
with open(args.json_file, "r", encoding="utf-8") as fh:
bundle = json.load(fh)
except (OSError, json.JSONDecodeError) as e:
print(f"error: could not read JSON bundle: {e}", file=sys.stderr)
return 1
if not isinstance(bundle, dict):
print("error: JSON bundle must be an object (from 'weekly_report.py gather')",
file=sys.stderr)
return 1
html_doc = build_html(bundle, title=args.title)
if args.output:
try:
with open(args.output, "w", encoding="utf-8") as fh:
fh.write(html_doc)
except OSError as e:
print(f"error: could not write {args.output}: {e.strerror or e}",
file=sys.stderr)
return 1
print(args.output)
else:
sys.stdout.write(html_doc)
return 0
if __name__ == "__main__":
sys.exit(main())
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |