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/test_render_html.py
View on GitHub#!/usr/bin/env python3
"""Offline unit tests for render_html — no I/O, pure bundle → HTML string.
Run: python3 test_render_html.py
"""
import json
import unittest
import render_html as rh
BUNDLE = {
"range": {"start": "2026-06-22", "end": "2026-06-28", "label": "this-week"},
"projects": {
"projects": [{"project": "Contoso", "hours": 8.0, "hours_prev": 6.0},
{"project": "Acme", "hours": 2.5, "hours_prev": 5.0}],
"tasks": [{"title": "Fix <bug> & ship", "project": "Contoso", "hours": 5.0},
{"title": "Docs", "project": "Contoso", "hours": 3.0}],
"total_ms": 0,
},
"notes": {"count": 1, "by": "modified", "dropped": 2, "notes": [
{"rel": "a.md", "name": "Note A", "modified": "2026-06-23",
"created": "2026-06-20", "body": "line1\nline2 <script>", "truncated": True},
]},
"emails": {"count": 1, "mailbox": "sent", "possibly_truncated": True, "emails": [
{"id": "1", "date": "2026-06-24", "to": ["x@y.com"],
"subject": "Hi & bye", "snippet": "hello"},
]},
"calendar": {"count": 3, "events": [
{"summary": "Standup", "day": "2026-06-23", "start_local": "09:00",
"end_local": "09:15", "all_day": False, "location": "Zoom",
"start": "2026-06-23T09:00:00+02:00", "end": "2026-06-23T09:15:00+02:00"},
{"summary": "Planning", "day": "2026-06-24", "start_local": "10:00",
"end_local": "11:00", "all_day": False, "location": "",
"start": "2026-06-24T10:00:00+02:00", "end": "2026-06-24T11:00:00+02:00"},
{"summary": "Holiday", "day": "2026-06-25", "all_day": True, "location": ""},
]},
"visits": {"sites": [
{"site_id": "abc-123", "name": "site.com", "visitors": 120, "visitors_prev": 100,
"visits": 130, "visits_prev": 140, "pageviews": 300, "pageviews_prev": 300,
"bounce_pct": 42.0, "avg_duration": 95, "avg_duration_prev": 80},
]},
"errors": ["visits: umami down"],
}
class TestBuild(unittest.TestCase):
def setUp(self):
self.html = rh.build_html(BUNDLE, title="Week 26")
def test_is_html_document(self):
self.assertTrue(self.html.startswith("<!DOCTYPE html>"))
self.assertIn("</html>", self.html)
def test_heading_and_range(self):
self.assertIn("Week 26", self.html)
self.assertIn("2026-06-22 → 2026-06-28", self.html)
def test_tldr_rendered_when_summary_present(self):
b = dict(BUNDLE)
b["summary"] = {"line": "8.0h across 2 projects · 34 visitor(s)"}
html = rh.build_html(b)
self.assertIn('class="tldr"', html)
self.assertIn("8.0h across 2 projects", html)
# No TL;DR block when there's no summary.
self.assertNotIn('class="tldr"', rh.build_html(dict(BUNDLE)))
def test_each_section_is_a_collapsible(self):
for title in ("Projects & time", "Obsidian Notes", "Emails sent",
"Calendar", "Visits vs last week"):
self.assertIn(title, self.html)
self.assertGreaterEqual(self.html.count("<details"), 5)
def test_calendar_has_only_day_and_event(self):
self.assertNotIn("<th>When</th>", self.html)
self.assertNotIn("<th>Location</th>", self.html)
self.assertIn("<th>Day</th>", self.html)
self.assertIn("<th>Event</th>", self.html)
def test_notes_hide_created_field(self):
# Note subtitle shows only the modified date, not created.
self.assertNotIn("2026-06-20", self.html) # BUNDLE note's created date
self.assertIn("mod 2026-06-23", self.html)
def test_projects_total_and_tasks(self):
self.assertIn("10.5h", self.html) # 8.0 + 2.5 total badge/foot
self.assertIn("5.0h", self.html) # task hours
def test_projects_week_over_week_badges(self):
# Contoso 8.0h vs 6.0h prev → ▲33%; Acme 2.5h vs 5.0h → ▼50%.
self.assertIn("▲33%", self.html)
self.assertIn("▼50%", self.html)
def test_html_is_escaped(self):
# Tags coming from DATA (note body, task title) must be escaped so they
# can't inject markup — the page's own <script> control is unrelated.
self.assertIn("line2 <script>", self.html) # from the note body
self.assertIn("Fix <bug> & ship", self.html)
self.assertNotIn("line2 <script>", self.html)
def test_notes_dropped_and_truncated_hints(self):
self.assertIn("+2 more note(s)", self.html)
self.assertIn("body truncated", self.html)
def test_notes_grouped_by_folder(self):
b = dict(BUNDLE)
b["notes"] = {"count": 2, "by": "modified", "notes": [
{"rel": "Acme/IA/a.md", "name": "A", "group": "Acme",
"modified": "2026-06-23", "created": "2026-06-20", "body": "x"},
{"rel": "EmailOps/b.md", "name": "B", "group": "EmailOps",
"modified": "2026-06-24", "created": "2026-06-21", "body": "y"},
]}
html = rh.build_html(b)
self.assertIn('class="note-group"', html)
self.assertIn(">Acme<", html)
self.assertIn(">EmailOps<", html)
def test_visits_delta_directions(self):
self.assertIn("delta up", self.html) # visitors 120 > 100
self.assertIn("delta down", self.html) # visits 130 < 140
self.assertIn("delta flat", self.html) # pageviews equal
def test_errors_footer(self):
self.assertIn("Skipped sources", self.html)
self.assertIn("visits: umami down", self.html)
def test_no_git_section_without_git_key(self):
self.assertNotIn("Git activity", self.html)
def test_sections_live_in_layout_container(self):
# Structure, not CSS: the sections layout container exists and holds the
# section cards (restyling the grid must not break this test).
self.assertIn('class="sections"', self.html)
container = self.html.split('class="sections"', 1)[1]
self.assertIn('<details class="section"', container)
def test_sections_expanded_by_default(self):
# All top-level section cards render open; nested notes/projects don't.
self.assertGreaterEqual(self.html.count('<details class="section" open>'), 5)
self.assertIn('<details class="note">', self.html) # nested stays closed
def test_section_order_is_grid_layout(self):
# DOM order = reading order across the 3-col grid: projects, calendar,
# (git), notes, emails, visits.
order = [self.html.index(t) for t in
("Projects & time", "Calendar", "Notes",
"Emails sent", "Visits vs last week")]
self.assertEqual(order, sorted(order))
def test_projects_section_expandable_no_duplicate_table(self):
# Projects appear once as expandable rows; no separate overview table.
self.assertNotIn("<th>Project</th>", self.html)
self.assertIn('class="total-row"', self.html)
self.assertIn('<details class="note">', self.html) # each project expands
def test_visits_has_bounce_and_avg_columns(self):
self.assertIn("<th>Bounce</th>", self.html)
self.assertIn("<th>Avg. visit</th>", self.html)
self.assertIn("42.0%", self.html) # bounce value
self.assertIn("1m 35s", self.html) # avg_duration 95s formatted
def test_visits_shows_site_id(self):
self.assertIn('class="sid"', self.html)
self.assertIn("abc-123", self.html)
def test_inline_style_and_no_garbage_tokens(self):
# Structure: the page carries an inline <style> block (self-contained,
# no external CSS) — we don't pin any specific colour/gradient literal.
self.assertIn("<style>", self.html)
self.assertIn("</style>", self.html)
# No stray autocomplete-garbage tokens leaked into the output.
self.assertNotIn("companies", self.html)
self.assertNotIn("banned", self.html)
SESSIONS = {
"total_sessions": 3, "total_cost_usd": 16.75,
"projects": [
{"project": "hermes", "path": "~/CTO/hermes", "sessions": 2,
"cost_usd": 15.5, "entries": [
{"session_id": "s1", "title": "Wire <weekly> report",
"when": "2026-06-24 10:00", "duration": "1h2m", "prompts": 5,
"cost_usd": 12.5, "grade": "B", "rating": "moderate"},
{"session_id": "s2", "title": "Fix parser bug",
"when": "2026-06-23 09:00", "duration": "20m", "prompts": 2,
"cost_usd": 3.0, "grade": "A", "rating": "lean"}]},
{"project": "site", "path": "~/CTO/site", "sessions": 1,
"cost_usd": 1.25, "entries": [
{"session_id": "s3", "title": "Tweak CSS", "when": "2026-06-22 14:00",
"duration": "15m", "prompts": 1, "cost_usd": 1.25, "grade": "A",
"rating": "lean"}]},
],
}
class TestSessions(unittest.TestCase):
def setUp(self):
b = dict(BUNDLE)
b["sessions"] = SESSIONS
self.html = rh.build_html(b)
def test_section_and_projects_render(self):
self.assertIn("Claude Code sessions", self.html)
self.assertIn("hermes", self.html)
self.assertIn("Fix parser bug", self.html)
def test_cost_and_grade_shown(self):
self.assertIn("$12.50", self.html) # session cost
self.assertIn(">B<", self.html) # efficiency grade cell
def test_session_title_escaped(self):
self.assertIn("Wire <weekly> report", self.html)
self.assertNotIn("Wire <weekly> report", self.html)
def test_highlights_card_present(self):
band = self.html.split('class="highlights"')[1].split("</section>")[0]
self.assertIn("Claude sessions", band)
self.assertIn("API-eq", band)
def test_absent_key_renders_no_section(self):
# Base BUNDLE has no "sessions" key → section is a no-op (like git).
self.assertNotIn("Claude Code sessions", rh.build_html(dict(BUNDLE)))
class TestHighlights(unittest.TestCase):
def setUp(self):
# Bundle including git data so the repos card is populated.
self.bundle = dict(BUNDLE)
self.bundle["git"] = {"total": 9, "repos": [
{"repo": "hermes", "count": 6}, {"repo": "emailops", "count": 2},
{"repo": "site", "count": 1},
]}
self.html = rh.build_html(self.bundle)
def test_highlights_band_present(self):
self.assertIn('class="highlights"', self.html)
def test_all_cards(self):
for h in ("Hours worked", "Meetings", "Projects by time",
"Top repos by commits", "Site visits"):
self.assertIn(h, self.html)
def test_projects_pie_rendered(self):
band = self.html.split('class="highlights"')[1].split("</section>")[0]
self.assertIn('class="card pie', band) # pie card
self.assertIn("<svg", band) # inline SVG
self.assertIn('class="legend"', band) # legend
def test_total_hours_value(self):
# 8.0 + 2.5 = 10.5h total
self.assertRegex(self.html, r'class="stat">10\.5<span class="unit">h')
def test_meetings_count_and_total_time(self):
# 2 timed meetings (Standup 15m + Planning 60m = 1h 15m); Holiday is all-day.
self.assertRegex(self.html, r'Meetings</div><div class="stat">2<')
self.assertIn("1h 15m total", self.html) # total meeting time
self.assertIn("Planning", self.html) # longest meeting listed
self.assertRegex(self.html, r'Planning</span><span class="mdur">1h 00m')
def test_top_repos_ranked(self):
# hermes (6) should rank above emailops (2).
i_h = self.html.index("hermes")
i_e = self.html.index("emailops")
self.assertLess(i_h, i_e)
def test_pie_shows_top_six_plus_other(self):
many = {"range": {"start": "a", "end": "b"},
"projects": {"projects": [{"project": f"P{i}", "hours": i}
for i in range(9)], "tasks": []},
"notes": {"notes": []}, "emails": {"emails": []},
"calendar": {"events": []}, "visits": {"sites": []}}
out = rh.build_html(many)
band = out.split('class="highlights"')[1].split("</section>")[0]
# Pie keeps the top 6 (P8..P3) and folds the rest into "Other".
self.assertIn("P8", band)
self.assertIn("P3", band)
self.assertIn("Other", band)
self.assertNotIn(">P0<", band) # smallest folded away
def test_highlights_graceful_errors(self):
bundle = {"range": {"start": "a", "end": "b"},
"projects": {"error": "x"}, "notes": {"notes": []},
"emails": {"emails": []}, "calendar": {"error": "y"},
"visits": {"error": "z"}}
out = rh.build_html(bundle)
band = out.split('class="highlights"')[1].split("</section>")[0]
self.assertIn("projects unavailable", band)
self.assertIn("calendar unavailable", band)
# Hours/Meetings stat cards fall back to an em-dash.
self.assertIn('class="stat">—', band)
class TestGraceful(unittest.TestCase):
def test_error_sections_render_unavailable(self):
bundle = {"range": {"start": "a", "end": "b"},
"projects": {"error": "no SP_DATA_FILE"},
"notes": {"error": "no vault"},
"emails": {"error": "no cli"},
"calendar": {"error": "no auth"},
"visits": {"error": "no umami"}, "errors": []}
out = rh.build_html(bundle)
self.assertEqual(out.count("unavailable:"), 5)
self.assertNotIn("Skipped sources", out) # empty errors → no footer
def test_empty_sections(self):
bundle = {"range": {"start": "a", "end": "b"},
"projects": {"projects": [], "tasks": []},
"notes": {"notes": []}, "emails": {"emails": []},
"calendar": {"events": []}, "visits": {"sites": []}}
out = rh.build_html(bundle)
self.assertIn("No time tracked", out)
self.assertIn("No notes", out)
self.assertIn("No emails", out)
class TestGitSection(unittest.TestCase):
def test_git_section_rendered_when_present(self):
bundle = {"range": {"start": "a", "end": "b"},
"projects": {"projects": [], "tasks": []},
"notes": {"notes": []}, "emails": {"emails": []},
"calendar": {"events": []}, "visits": {"sites": []},
"git": {"total": 3, "repos": [
{"repo": "hermes", "count": 3, "insertions": 100, "deletions": 5,
"commits": [{"short": "abc1234", "date": "2026-06-24",
"subject": "add thing"}]},
]}}
out = rh.build_html(bundle)
self.assertIn("Git activity", out)
self.assertIn("abc1234", out)
self.assertIn("add thing", out)
self.assertIn("+100/-5", out)
# Git activity sits in column 3 of row 1 (after Calendar, before Notes).
self.assertLess(out.index("Calendar"), out.index("Git activity"))
self.assertLess(out.index("Git activity"), out.index("Notes"))
class TestEmailsRecipient(unittest.TestCase):
def _html(self, to):
bundle = {"range": {"start": "a", "end": "b"},
"projects": {"projects": [], "tasks": []}, "notes": {"notes": []},
"emails": {"emails": [{"date": "2026-06-24",
"subject": "Project coordination", "to": to}]},
"calendar": {"events": []}, "visits": {"sites": []}}
return rh.build_html(bundle)
def test_no_to_column(self):
out = self._html(["carla.diaz@contoso.com"])
self.assertNotIn("<th>To</th>", out)
def test_first_recipient_inline_with_subject(self):
out = self._html(["carla.diaz@contoso.com", "b@y.com"])
# "Project coordination (carla.diaz@contoso.com)" with full list on hover.
self.assertIn("Project coordination", out)
self.assertIn("(carla.diaz@contoso.com)", out)
self.assertIn('title="carla.diaz@contoso.com, b@y.com"', out)
def test_no_recipient_no_parens(self):
out = self._html([])
self.assertNotIn('class="rcpt"', out)
class TestHelpers(unittest.TestCase):
def test_section_error(self):
self.assertEqual(rh.section_error({"error": "x"}), "x")
self.assertIsNone(rh.section_error({"ok": 1}))
def test_fmt_hours(self):
self.assertEqual(rh.fmt_hours(3), "3.0h")
self.assertEqual(rh.fmt_hours(None), "0.0h")
def test_valid_json_roundtrip_input(self):
# The renderer must accept exactly what gather emits (a JSON object).
parsed = json.loads(json.dumps(BUNDLE))
self.assertIn("<!DOCTYPE html>", rh.build_html(parsed))
class TestBadgeCoercion(unittest.TestCase):
def test_string_counts_cannot_inject_markup(self):
# Badges pass through details() unescaped (they can carry delta HTML) —
# counts from a tampered bundle must be int-coerced, not interpolated.
html = rh.render_git({"repos": [{"repo": "r", "commits": [],
"count": "1<img src=x onerror=alert(1)>"}],
"total": "2<script>"})
self.assertNotIn("<img", html)
self.assertNotIn("<script>", html)
html = rh.render_sessions({"projects": [{"project": "p", "entries": [],
"sessions": "3<script>"}],
"total_sessions": "4<script>"})
self.assertNotIn("<script>", html)
if __name__ == "__main__":
unittest.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 |