Skip to content

Develop#51

Merged
Maciek-roboblog merged 9 commits intomainfrom
develop
Jun 24, 2025
Merged

Develop#51
Maciek-roboblog merged 9 commits intomainfrom
develop

Conversation

@Maciek-roboblog
Copy link
Owner

@Maciek-roboblog Maciek-roboblog commented Jun 24, 2025

Summary by CodeRabbit

  • New Features
    • Introduced a modular usage analysis engine with new data models, session block identification, burn rate calculations, and JSON output formatting.
    • Added a direct usage analyzer API, eliminating the need for external CLI tools.
  • Bug Fixes
    • Improved timezone handling by standardizing all internal datetime operations to UTC and ensuring accurate reset time calculations.
  • Documentation
    • Updated and streamlined all documentation to remove references to automatic Node.js/ccusage installation and related troubleshooting.
    • Deleted the detailed CLAUDE.md developer guide.
    • Added and updated changelog and TODO entries.
  • Chores
    • Disabled all GitHub Actions workflows for linting, release, and version bumping.
    • Updated project version to 1.0.19.
  • Refactor
    • Removed subprocess-based data fetching and legacy reset time logic.
    • Reorganized codebase into modular packages for core logic, models, output, and utilities.

@coderabbitai
Copy link

coderabbitai bot commented Jun 24, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update introduces a new internal usage analysis module (usage_analyzer) with structured data models, session logic, burn rate calculations, and output formatting. The main script (claude_monitor.py) is refactored to use this module directly, removing all subprocess calls to the external ccusage CLI. Internal time handling is unified to UTC. Documentation and all GitHub Actions workflows are disabled or cleaned up.

Changes

Files / Paths Change Summary
.github/workflows/*.yml All GitHub Actions workflows (lint, release, version-bump) fully commented out (disabled).
CHANGELOG.md, TODO.md, TROUBLESHOOTING.md, README.md, CLAUDE.md Documentation updated: new changelog entry, TODO item added, troubleshooting and README cleaned of ccusage/Node.js, CLAUDE.md deleted.
check_dependency.py Deleted script for checking Node.js/npx dependencies.
pyproject.toml Project version updated from 1.0.18 to 1.0.19.
claude_monitor.py Refactored: removed all ccusage subprocess logic, now imports and uses analyze_usage() from new internal API; unified UTC time handling; reset time logic simplified.
usage_analyzer/api.py New: Main API for usage analysis; loads data, identifies session blocks, computes burn rates, formats JSON output.
usage_analyzer/core/init.py, usage_analyzer/core/calculator.py, ... New: Core logic for session block identification, burn rate calculation, and data loading.
usage_analyzer/models/init.py, usage_analyzer/models/data_structures.py New: Data models and enums for usage entries, session blocks, token counts, burn rates, projections.
usage_analyzer/output/init.py, usage_analyzer/output/json_formatter.py New: Output formatting for session blocks to JSON, including recalculated costs and token stats.
usage_analyzer/utils/init.py, usage_analyzer/utils/path_discovery.py, ... New: Utilities for path discovery, pricing calculations, and message counting.

Sequence Diagram(s)

sequenceDiagram
    participant MainScript as claude_monitor.py
    participant UsageAPI as usage_analyzer.api.analyze_usage
    participant DataLoader as DataLoader
    participant BlockIdentifier as SessionBlockIdentifier
    participant BurnRateCalc as BurnRateCalculator
    participant Formatter as JSONFormatter

    MainScript->>UsageAPI: analyze_usage()
    UsageAPI->>DataLoader: load_usage_data()
    DataLoader-->>UsageAPI: usage_entries
    UsageAPI->>BlockIdentifier: identify_blocks(usage_entries)
    BlockIdentifier-->>UsageAPI: session_blocks
    loop For each active block
        UsageAPI->>BurnRateCalc: calculate_burn_rate(block)
        UsageAPI->>BurnRateCalc: project_block_usage(block)
    end
    UsageAPI->>Formatter: format_blocks(session_blocks)
    Formatter-->>UsageAPI: formatted_json
    UsageAPI-->>MainScript: usage_data (dict)
Loading

Possibly related PRs

  • #47: Refactors to remove all subprocess calls to ccusage in favor of direct usage of analyze_usage() and unifies timezone handling—directly related to the main refactor in this PR.
  • #46: Simplifies and fixes the get_next_reset_time function to use a fixed timezone, which is related to the removal and replacement of reset time logic in this PR.

Suggested reviewers

  • kory-
  • PedramNavid
  • rvaidya
  • adawalli
  • eleloi

Poem

🐇
With workflows paused and docs made neat,
Old ccusage calls admit defeat.
Now UTC keeps time in line,
Internal modules work just fine.
Session blocks and tokens flow,
The monitor’s heart now set aglow!
— A rabbit’s hop to version one-point-one-nine.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 81703c6 and 1c70ea6.

📒 Files selected for processing (23)
  • .github/workflows/lint.yml (1 hunks)
  • .github/workflows/release.yml (1 hunks)
  • .github/workflows/version-bump.yml (1 hunks)
  • CHANGELOG.md (2 hunks)
  • CLAUDE.md (0 hunks)
  • README.md (2 hunks)
  • TODO.md (1 hunks)
  • TROUBLESHOOTING.md (0 hunks)
  • check_dependency.py (0 hunks)
  • claude_monitor.py (9 hunks)
  • pyproject.toml (1 hunks)
  • usage_analyzer/api.py (1 hunks)
  • usage_analyzer/core/__init__.py (1 hunks)
  • usage_analyzer/core/calculator.py (1 hunks)
  • usage_analyzer/core/data_loader.py (1 hunks)
  • usage_analyzer/core/identifier.py (1 hunks)
  • usage_analyzer/models/__init__.py (1 hunks)
  • usage_analyzer/models/data_structures.py (1 hunks)
  • usage_analyzer/output/__init__.py (1 hunks)
  • usage_analyzer/output/json_formatter.py (1 hunks)
  • usage_analyzer/utils/__init__.py (1 hunks)
  • usage_analyzer/utils/path_discovery.py (1 hunks)
  • usage_analyzer/utils/pricing_fetcher.py (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Maciek-roboblog Maciek-roboblog merged commit d79f388 into main Jun 24, 2025
AlexLoar pushed a commit to AlexLoar/Claude-Code-Usage-Monitor that referenced this pull request Jul 4, 2025
This was referenced Jul 13, 2025
@Maciek-roboblog Maciek-roboblog deleted the develop branch July 15, 2025 03:13
@Maciek-roboblog Maciek-roboblog restored the develop branch July 15, 2025 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants