"""Writes docs/werkrevisor-review-inside.svg and its dark variant: which files configure a review, which services it calls, and when.""" from html import escape LIGHT = dict(bg="#ffffff", text="#141616", muted="#55615f", soft="#3e4645", lane="#f3f6f5", card="#ffffff", line="#c9d3d1", main="#e7f1f3", main_line="#0e6b7d", num_bg="#0e6b7d", num_text="#ffffff", accent="#0e6b7d", chip_text="#ffffff", env="#eef1f0", warn="#fdf3e1", warn_line="#d9a441") DARK = dict(bg="#0d1312", text="#e9efed", muted="#9fb0ad", soft="#b7c4c1", lane="#17201f", card="#1e2927", line="#3a4a47", main="#132e35", main_line="#3aa3b8", num_bg="#3aa3b8", num_text="#0d1312", accent="#5cc3d6", chip_text="#ffffff", env="#1a2321", warn="#2e2615", warn_line="#c99a3a") SERVICES = { "local": ("#0e6b7d", "werkrevisor"), "Gitea": ("#5f6b69", "Gitea"), "Jev": ("#7446a8", "Jev"), "OpenRouter": ("#24733e", "OpenRouter"), "Stats": ("#3b6fb6", "Statistics"), } STEPS = [ ("Read the pull request", ["Gitea"], "always", "head, WIP title, earlier result and approval, files and diff; .werkrevisor.toml"), ("Rules", ["local"], "always", "hard paths, secrets, size, open questions, writing rules, mechanical files, images"), ("PR documents", ["Jev"], "engine classifier or combined", "each section and scenario: clear, specific, Gherkin used well"), ("DB changesets", ["Jev"], "schema files changed, judge = jev", "deploy risk, loss of existing data"), ("Each changed file", ["Jev"], "path judge with scope all", "weakened checks, security, and the categories of the risk template"), ("PR document vs each file", ["Jev"], "doc check, PR document changed", "contradiction, unrelated change, data outflow"), ("Context for the model", ["Gitea", "OpenRouter"], "full files on; excerpts for large files", "full files at the head; an economy model selects excerpt lines"), ("Model review", ["OpenRouter"], "not in classifier mode; budget left", "PR-Agent asks the model of the host config; it advises or decides"), ("Findings", ["Jev"], "the model reported findings", "real defect, severity, risk category"), ("Verdict and output", ["local", "Gitea", "Stats"], "always", "worst reason; RED for risk and finding in one file or category"), ("Diagrams", ["OpenRouter", "Gitea"], "[diagrams] enabled", "PR Lens draws the change; SVGs on the comment, not in the verdict"), ] CONFIGS = [ ("Host config", "machine config, WERKREVISOR_CONFIG_TOML", ["model, provider order, budget", "gate, engine, Jev endpoint", "risk template, doc check"], "2–11"), (".werkrevisor.toml", "repository, head of the default branch", ["hard and judged paths, DB schema", "PR document globs, writing rules", "Jev questions, risk template"], "1–5, 7–9"), ("Risk templates", "per ecosystem, in werkrevisor", ["jvm-spring-backend: 16 categories", "typescript-frontend: 15 categories", "tuned in .werkrevisor.toml"], "5, 9"), ("Built into werkrevisor", "code and defaults", ["questions for files and findings", "PR document check questions", "limits, timeouts, defaults"], "3–10"), ("Files of the pull request", "read at the head commit", ["PR documents, e.g. docs/prs/*.md", "AGENTS.md as context of the model", "changed files in full or as excerpt"], "3, 6–8"), ] def svg(c): out = [] add = out.append add('') add('Inside a werkrevisor review') add(f'''''') add(f'') add('Inside a werkrevisor review') add('Which files configure it, which services it calls, and when.') add(f'') add(f'') add(f'') add('CONFIGURATION') add('STEPS OF ONE REVIEW') add('ENVIRONMENT') y = 164 for title, sub, items, used in CONFIGS: h = 132 add(f'') add(f'{escape(title)}') add(f'steps {escape(used)}') add(f'{escape(sub)}') for i, item in enumerate(items): add(f'· {escape(item)}') y += h + 8 y = 162 row = 58 for n, (name, services, when, what) in enumerate(STEPS, 1): add(f'') add(f'') add(f'{n}') add(f'{escape(name)}') add(f'{escape(what)}') x = 1196 for s in reversed(services): color, label = SERVICES[s] w = 14 + 7.6 * len(label) x -= w add(f'') add(f'{escape(label)}') x -= 6 add(f'{escape(when)}') y += row add(f'') add(f'A possible secret in the diff: nothing goes to Jev or a model, and the review is YELLOW.') envs = [ ("werkrevisor", "Werkator", "#0e6b7d", ["starts a review for each head commit,", "its exit code is the merge gate"]), ("Gitea", "Gitea", "#5f6b69", ["reads the PR; writes the comment,", "line comments, status, approval, merge"]), ("Jev", "TypeSafe · Jev", "#7446a8", ["typed questions, probabilities;", "about 0.001 USD per review"]), ("OpenRouter", "OpenRouter", "#24733e", ["MiniMax M3: model review;", "GPT-6 Luna: excerpts; key budget"]), ("Stats", "Statistics service", "#3b6fb6", ["usage record with costs", "and seconds per phase"]), ] y = 164 for _, label, color, lines in envs: add(f'') add(f'') add(f'') add(f'{escape(label)}') for i, line in enumerate(lines): add(f'{escape(line)}') y += 140 add('git.javagil.de/mi/werkrevisor') add('') return "\n".join(out) + "\n" if __name__ == "__main__": import sys target = sys.argv[1] if len(sys.argv) > 1 else "docs" open(f"{target}/werkrevisor-review-inside.svg", "w").write(svg(LIGHT)) open(f"{target}/werkrevisor-review-inside-dark.svg", "w").write(svg(DARK))