Skip to content

thedotmack/claude-mem / plugin/skills/agent-cost-report

agent-cost-report

Verified

Believable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.

FileKindSize
.gitignoreother100 B
CHECKSUMS.txtmarkdown2.1 KB
SKILL.mdskill md21.3 KB
VERIFICATION.mdmarkdown12.3 KB
scripts/acr.pyexecutablescript12.2 KB
scripts/acr/__init__.pyscript105 B
scripts/acr/behavior.pyscript17.5 KB
scripts/acr/classify.pyscript5.5 KB
scripts/acr/costs.pyscript6.3 KB
scripts/acr/devices.pyscript5.4 KB
scripts/acr/evidence.pyscript9.2 KB
scripts/acr/labels.pyscript7.6 KB
scripts/acr/measure.pyscript5.6 KB
scripts/acr/mistakes.pyscript23.1 KB
scripts/acr/owner.pyscript2.9 KB
scripts/acr/patterns.pyscript26.0 KB
scripts/acr/period.pyscript3.8 KB
scripts/acr/prices.pyscript5.0 KB
scripts/acr/render.pyscript52.7 KB
scripts/acr/rollup.pyscript31.7 KB
scripts/acr/rules.jsonconfig3.5 KB
scripts/acr/rules.pyscript4.5 KB
scripts/acr/sample.pyscript3.6 KB
scripts/acr/snapshot.pyscript2.0 KB
scripts/acr/sync.pyscript3.7 KB
scripts/acr/transcripts.pyscript7.4 KB
scripts/acr/wins.pyscript21.0 KB
scripts/tests/_db.pyscript3.6 KB
scripts/tests/_paths.pyscript337 B
scripts/tests/fixtures/codex/sessions/2026/09/18/rollout-codex-1.jsonlother664 B
scripts/tests/fixtures/make_report_fixtures.pyscript2.0 KB
scripts/tests/fixtures/prices_sample.jsonconfig611 B
scripts/tests/fixtures/projects/-workspace-proj-a/sess-aaaa.jsonlother2.9 KB
scripts/tests/fixtures/projects/-workspace-proj-b/sess-bbbb.jsonlother537 B
scripts/tests/fixtures/report-1day.jsonconfig20.1 KB
scripts/tests/fixtures/report-30day.jsonconfig48.1 KB
scripts/tests/fixtures/report-7day.jsonconfig29.1 KB
scripts/tests/fixtures/report-empty.jsonconfig13.8 KB
scripts/tests/fixtures/report-session.jsonconfig16.6 KB
scripts/tests/test_behavior.pyscript29.6 KB
scripts/tests/test_devices.pyscript5.9 KB
scripts/tests/test_labels.pyscript8.6 KB
scripts/tests/test_measure.pyscript6.8 KB
scripts/tests/test_period.pyscript7.0 KB
scripts/tests/test_prices.pyscript5.3 KB
scripts/tests/test_render.pyscript12.1 KB
scripts/tests/test_render_encoding.pyscript1.5 KB
scripts/tests/test_rollup.pyscript20.0 KB
scripts/tests/test_snapshot.pyscript2.8 KB
scripts/tests/test_sync.pyscript2.5 KB
scripts/tests/test_transcript_encoding.pyscript2.7 KB
scripts/tests/test_transcripts.pyscript8.1 KB
scripts/tests/test_wins.pyscript15.7 KB
verification/precision-2026-09-26.jsonconfig308 B

scripts/acr/period.py

View on GitHub
"""PT period window (plan Phase 1.2).

Period arguments copied from /workspace/weekly-cost-workflow/parse_transcripts.py:8-14 and
weekly_report.py:11-14 (PT calendar days, end exclusive, ZoneInfo only), with defaults added
per the plan (G3): last 7 full PT days, today excluded. No fixed UTC offsets anywhere.
"""
import datetime as dt
import re
from dataclasses import dataclass
from zoneinfo import ZoneInfo

# copied from /workspace/weekly-cost-workflow/parse_transcripts.py:9 (same at weekly_report.py:11)
PT = ZoneInfo("America/Los_Angeles")

DEFAULT_DAYS = 7


DAY_RE = re.compile(r"^\d{4}-\d{2}-\d{2}$")


def parse_day(text):
    """'YYYY-MM-DD' (a PT calendar day) -> aware datetime at PT midnight.
    copied from parse_transcripts.py:10-11 / weekly_report.py:13-14:
    dt.datetime.fromisoformat(x).replace(tzinfo=PT). Strict: anything but a bare calendar day is
    rejected (datetime.fromisoformat would silently accept '2026-09-25+00:00' as a naive midnight)."""
    if not DAY_RE.match(text or ""):
        raise ValueError(f"expected a PT calendar day YYYY-MM-DD, got {text!r}")
    return dt.datetime.fromisoformat(text).replace(tzinfo=PT)


def epoch_ms(d):
    """copied from weekly_report.py:13-14: int(<aware dt>.timestamp() * 1000) -> UTC epoch milliseconds."""
    return int(d.timestamp() * 1000)


def pt_midnight(day):
    """Aware datetime at 00:00 PT on the given date (never ambiguous: DST switches at 02:00)."""
    return dt.datetime.combine(day, dt.time(0), tzinfo=PT)


def now_pt():
    return dt.datetime.now(PT)


@dataclass(frozen=True)
class Window:
    start: dt.datetime        # aware PT midnight; transcripts test s <= t < e
    end: dt.datetime          # aware PT midnight, exclusive
    generated_at: dt.datetime  # aware, PT

    @property
    def start_pt(self):
        return self.start.date().isoformat()

    @property
    def end_exclusive_pt(self):
        return self.end.date().isoformat()

    @property
    def start_epoch_ms(self):
        return epoch_ms(self.start)

    @property
    def end_epoch_ms(self):
        return epoch_ms(self.end)

    @property
    def generated_at_pt(self):
        return self.generated_at.strftime("%Y-%m-%d %H:%M PT")

    @property
    def partial_last_day(self):
        # Only an explicit --end later than today's PT date puts a not-yet-finished day in the window.
        # The default window ends at the midnight that started today, so this is False by construction.
        return self.end.date() > self.generated_at.date()

    def block(self):
        """The `window` block every output carries (shape after weekly_report.py:207-238 `window=`)."""
        return dict(start_pt=self.start_pt, end_exclusive_pt=self.end_exclusive_pt,
                    start_epoch_ms=self.start_epoch_ms, end_epoch_ms=self.end_epoch_ms,
                    generated_at_pt=self.generated_at_pt, partial_last_day=self.partial_last_day)


def resolve_window(start=None, end=None, now=None):
    """Build the PT window from optional --start/--end strings.

    Defaults (plan G3): end = the PT midnight that started today (today excluded);
    start = end - 7 days. `now` is injectable for tests (an aware datetime)."""
    now = (now or now_pt()).astimezone(PT)
    e = parse_day(end) if end is not None else pt_midnight(now.date())
    s = parse_day(start) if start is not None else pt_midnight(e.date() - dt.timedelta(days=DEFAULT_DAYS))
    if not s < e:
        raise ValueError(f"--start {s.date()} must be before --end {e.date()} (end is exclusive)")
    return Window(s, e, now)


def session_block(session, now=None):
    """`window` block for --session runs: no period filter, so the bounds are null."""
    now = (now or now_pt()).astimezone(PT)
    return dict(start_pt=None, end_exclusive_pt=None, start_epoch_ms=None, end_epoch_ms=None,
                generated_at_pt=now.strftime("%Y-%m-%d %H:%M PT"), partial_last_day=False, session=session)
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
backup-setupthedotmack/claude-memSet up, check, or restore local claude-mem database snapshots. Use when the user says "set up backups", "back up my memories", "backup status", or "restore my database".Stars: 118kUpdated Claude CodeCodexVerifiedInstall