Skip to content

gerodp/hermes-productivity-skills / reports/weekly-report

weekly-report

Verified

One 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.

scripts/test_render_markdown.py

View on GitHub
#!/usr/bin/env python3
"""Offline unit tests for render_markdown — pure bundle → Markdown string.

Run:  python3 test_render_markdown.py
"""
import unittest

import render_markdown as rm


BUNDLE = {
    "range": {"start": "2026-06-22", "end": "2026-06-28", "label": "this-week"},
    "summary": {"line": "8.0h across 2 project(s) · 34 visitor(s)"},
    "projects": {"projects": [
        {"project": "Contoso", "hours": 8.0, "hours_prev": 6.0},
        {"project": "Acme", "hours": 2.5, "hours_prev": 5.0}]},
    "notes": {"count": 2, "by": "modified", "notes": [
        {"rel": "Acme/IA/a.md", "name": "Plan IA", "group": "Acme",
         "modified": "2026-06-23", "created": "2026-06-20", "body": "line1\nline2"},
        {"rel": "Ideas.md", "name": "Ideas", "group": "(root)",
         "modified": "2026-06-25", "created": "2026-06-01", "body": ""}]},
    "emails": {"count": 1, "mailbox": "sent", "emails": [
        {"id": "1", "date": "2026-06-24", "to": ["antxon@x.com"],
         "subject": "facturas T2 | subidas"}]},
    "calendar": {"count": 1, "events": [
        {"summary": "Standup", "day": "2026-06-23", "start_local": "09:00",
         "end_local": "09:15", "all_day": False, "location": "Zoom"}]},
    "git": {"total": 2, "repos": [
        {"repo": "hermes", "count": 2, "insertions": 40, "deletions": 5, "commits": [
            {"short": "aaa1", "date": "2026-06-24", "subject": "add x"},
            {"short": "bbb2", "date": "2026-06-23", "subject": "fix y"}]}]},
    "sessions": {"total_sessions": 1, "total_cost_usd": 12.5, "projects": [
        {"project": "hermes", "sessions": 1, "cost_usd": 12.5, "entries": [
            {"session_id": "s1", "title": "Wire report", "when": "2026-06-24 10:00",
             "duration": "1h", "prompts": 5, "cost_usd": 12.5, "grade": "B"}]}]},
    "visits": {"sites": [
        {"site_id": "abc-123", "name": "FractionalCTO", "visitors": 21,
         "visitors_prev": 27, "visits": 28, "visits_prev": 30, "pageviews": 33,
         "pageviews_prev": 35, "bounce_pct": 85.7, "avg_duration": 180},
        {"site_id": "def-456", "name": "GetEmailOps", "visitors": 20,
         "visitors_prev": 7, "visits": 22, "pageviews": 23, "bounce_pct": 95.5,
         "avg_duration": 2}]},
    "errors": [],
}


class TestMarkdown(unittest.TestCase):
    def setUp(self):
        self.md = rm.build_markdown(BUNDLE, title="Week 26")

    def test_heading_and_tldr(self):
        self.assertIn("# Week 26", self.md)
        self.assertIn("**TL;DR:** 8.0h across 2 project(s)", self.md)

    def test_all_sections_present(self):
        for h in ("## Projects & time", "## Calendar", "## Git activity",
                  "## Claude Code sessions", "## Notes this week",
                  "## Emails sent", "## Visits vs last week"):
            self.assertIn(h, self.md)

    def test_emails_row_rendered_verbatim(self):
        # The whole point: the real email row must appear, never a placeholder.
        self.assertIn("antxon@x.com", self.md)
        self.assertIn("facturas T2", self.md)
        self.assertIn("**1 email(s) sent this week.**", self.md)
        self.assertNotIn("see source", self.md)
        self.assertNotIn("included in bundle", self.md)

    def test_visits_real_site_names_and_ids(self):
        for name in ("FractionalCTO", "GetEmailOps"):
            self.assertIn(name, self.md)
        self.assertIn("abc-123", self.md)
        self.assertIn("| **Total** |", self.md)   # totals row
        self.assertIn("41", self.md)               # 21 + 20 total visitors

    def test_pipe_in_data_escaped(self):
        # Subject "facturas T2 | subidas" must not break the table.
        self.assertIn("facturas T2 \\| subidas", self.md)

    def test_projects_delta_column(self):
        self.assertIn("Δ vs prev", self.md)
        self.assertIn("▲33%", self.md)    # Contoso 8 vs 6
        self.assertIn("▼50%", self.md)    # Acme 2.5 vs 5

    def test_notes_grouped_with_bodies(self):
        self.assertIn("### Acme", self.md)
        self.assertIn("> line1", self.md)   # body rendered verbatim

    def test_sessions_cost_disclaimer(self):
        self.assertIn("not your subscription bill", self.md)

    def test_error_section_degrades(self):
        b = dict(BUNDLE)
        b["visits"] = {"error": "UMAMI_URL not set"}
        md = rm.build_markdown(b)
        self.assertIn("_unavailable: UMAMI_URL not set_", md)

    def test_git_absent_key_no_section(self):
        b = {k: v for k, v in BUNDLE.items() if k not in ("git", "sessions")}
        md = rm.build_markdown(b)
        self.assertNotIn("## Git activity", md)
        self.assertNotIn("## Claude Code sessions", md)


class TestMdCellEscaping(unittest.TestCase):
    def test_link_brackets_escaped(self):
        # An email subject must not become a live (phishing) link in the report.
        self.assertEqual(rm.md_cell("[pay now](https://evil)"),
                         "\\[pay now\\](https://evil)")


if __name__ == "__main__":
    unittest.main()
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: 472kUpdated Claude CodeCodexVerifiedInstall
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: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
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 availableStars: 322kUpdated Claude CodeCodexVerifiedInstall