Skip to content

netresearch/matrix-skill / skills/matrix-administration

matrix-administration

Verified

Use when administering a Synapse / Matrix homeserver — list or snapshot all rooms, rate room health (public, unencrypted, orphaned), render a Graphviz map of the room/space tree, force-join users, promote room admins, harden rooms (add-to-space + restrict + encrypt), deactivate Matrix users (with GDPR erase), find biggest rooms by DB size, audit where a user is admin or member, replay join/leave timelines, or search unencrypted history. Trigger on any '/_synapse/admin', server-wide room operation, Matrix user offboarding, or anything requiring a homeserver-admin token — even without 'admin API' in the prompt. Companion to matrix-communication.

scripts/_lib/pretty_bytes.py

View on GitHub
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: Netresearch DTT GmbH

"""Human-readable byte-size formatter.

Decimal units by default (``kB``, ``MB``, ``GB`` …); pass ``binary=True``
for IEC units (``KiB``, ``MiB`` …).  Stdlib only.
"""

from __future__ import annotations

import math

_BYTE_UNITS = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
_BIBYTE_UNITS = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]


def pretty_bytes(number: float, binary: bool = False, space: bool = True) -> str:
    """Format ``number`` of bytes with a human-readable unit.

    Examples
    --------
    >>> pretty_bytes(0)
    '0 B'
    >>> pretty_bytes(1500)
    '1.50 kB'
    >>> pretty_bytes(1500, binary=True)
    '1.46 KiB'
    """
    if isinstance(number, float) and not math.isfinite(number):
        raise ValueError(f"Expected a finite number, got: {number!r}")

    units = _BIBYTE_UNITS if binary else _BYTE_UNITS
    sep = " " if space else ""

    sign = "-" if number < 0 else ""
    n = abs(number)

    if n < 1:
        return f"{sign}{n:.0f}{sep}{units[0]}"

    base = 1024 if binary else 1000
    exponent = 0
    while n >= base and exponent < len(units) - 1:
        n /= base
        exponent += 1

    if n >= 100:
        formatted = f"{n:.0f}"
    elif n >= 10:
        formatted = f"{n:.1f}"
    else:
        formatted = f"{n:.2f}"

    return f"{sign}{formatted}{sep}{units[exponent]}"
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 469kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 469kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 469kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall