Metadata-Version: 2.4
Name: github-clc
Version: 3.0.0
Summary: Track your daily lines of code across all GitHub repositories.
Author-email: Rudra Tiwari <tiwarirudra2006@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/Rudra-Tiwari-codes/CLC
Project-URL: Repository, https://github.com/Rudra-Tiwari-codes/CLC
Project-URL: Issues, https://github.com/Rudra-Tiwari-codes/CLC/issues
Keywords: github,stats,loc,lines-of-code,developer-tools,productivity
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Version Control :: Git
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.31.0
Requires-Dist: python-dotenv>=1.0.0
Dynamic: license-file

﻿<div align="center">

# CLC - Commit Line Counter

**Track lines of code across all your GitHub repositories.**

Get terminal stats, SVG cards for your profile, or a full HTML dashboard. Runs locally or on a cron via GitHub Actions.

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/)
[![GitHub stars](https://img.shields.io/github/stars/Rudra-Tiwari-codes/CLC?style=social)](https://github.com/Rudra-Tiwari-codes/CLC)

</div>

---

## Quick start

```bash
git clone https://github.com/Rudra-Tiwari-codes/CLC.git
cd CLC
pip install -r requirements.txt
```

Create a GitHub Personal Access Token (classic) with `repo` + `read:user` scopes at [github.com/settings/tokens](https://github.com/settings/tokens).

```bash
export GITHUB_TOKEN=ghp_xxxxxxxxxxxx
# or create a .env file with GITHUB_TOKEN=ghp_xxxxxxxxxxxx
```

## Usage

```bash
python daily_loc.py              # Last 30 days, terminal output
python daily_loc.py -d 7         # Last week
python daily_loc.py -d 90        # Last quarter
python daily_loc.py -u octocat   # Specific user
python daily_loc.py --max-repos 50         # Limit to 50 most recently pushed repos
python daily_loc.py -o stats.json          # Export to JSON
python daily_loc.py --clear-cache          # Wipe cached data
python daily_loc.py --exclude "fork|test"  # Skip repos matching regex
```

### SVG card generation

```bash
python daily_loc.py --svg card.svg                     # Dark theme (default)
python daily_loc.py --svg card.svg --theme radical      # Radical theme
python daily_loc.py --svg card.svg --theme tokyonight   # Tokyo Night theme
python daily_loc.py --svg card.svg --no-animate         # Disable CSS animations
```

### Custom themes

Use any 3 hex colors (background, text, accent):

```bash
python daily_loc.py --svg card.svg --theme "#1a1a2e,#eaeaea,#e94560"
```

### Weekly / monthly rollups

```bash
python daily_loc.py --svg card.svg --group weekly    # Group by week
python daily_loc.py --svg card.svg --group monthly   # Group by month
```

### Comparison mode

Compare your stats against any public GitHub user:

```bash
python daily_loc.py -d 30 --svg card.svg --vs torvalds
```

### Multi-user leaderboard

Compare 3+ users side by side with a ranked leaderboard card:

```bash
python daily_loc.py --svg card.svg --leaderboard "antfu,craftzdog,sindresorhus"
```

Generates a separate `*-leaderboard.svg` with gold/silver/bronze rankings.

### Interactive HTML dashboard

Generate a self-contained HTML report with interactive Chart.js charts:

```bash
python daily_loc.py --html report.html
```

Includes daily activity charts, language doughnut, coding hours distribution, top files, code churn, commit message patterns, achievements, and stat cards.

### Historical trends

Track your stats over time in a local JSON history file:

```bash
python daily_loc.py --history              # Append today's stats to .clc-history.json
python daily_loc.py --history -d 7         # Track weekly snapshots
```

### Contributor rank

See your rank among contributors in repos you contribute to:

```bash
python daily_loc.py --contributor-rank
```

### Dark hours & work schedule

Configure what counts as "work hours" for the dark hours tracker:

```bash
python daily_loc.py --work-hours "8-18"    # 8 AM to 6 PM
```

### Exclude patterns

Skip repos matching a regex pattern:

```bash
python daily_loc.py --exclude "fork|archived|test"
```

### Shields.io badge JSON

Generate endpoint JSON files for dynamic shields.io badges:

```bash
python daily_loc.py --badge-json badges/
```

This creates `badges/loc.json`, `badges/commits.json`, `badges/streak.json`, and `badges/net.json`. Use them with shields.io endpoint badges:

```markdown
![LOC](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/YOUR_USER/YOUR_USER/main/badges/loc.json)
```

---

## Features

| Feature | Description |
|---------|-------------|
| **Language Breakdown** | Detects 50+ languages from file extensions, shows donut chart on SVG card |
| **File Type Treemap** | Visual proportional treemap of languages in the SVG card |
| **Repository Leaderboard** | Top repos ranked by total lines changed |
| **Productivity Scoring** | Each day rated: Low / Medium / High / Beast Mode (based on percentiles) |
| **Streak Tracking** | Current and longest consecutive coding streaks |
| **Achievements** | Unlockable milestones: 1K Club, Week Warrior, Polyglot, Power Day, etc. |
| **Net LOC Trend** | Sparkline graph showing your net output trend over time |
| **Code Velocity** | Lines per day average with trend direction (up/down/stable) and peak day |
| **Code Churn** | Tracks files changed repeatedly -- high churn flags unstable code |
| **Top Files Changed** | Lists files with the most lines added/deleted |
| **Commit Message Analysis** | Most common words in your commit messages (stop-word filtered) |
| **Repo Health Score** | 0-100 composite from commit frequency, streak, diversity, breadth, volume |
| **Dark Hours Tracker** | Coding done outside configurable work hours, night owl score, peak hour |
| **Git Blame Depth** | Code survival rate -- how much of your code persists vs gets deleted |
| **Contributor Rank** | Your rank among all contributors in repos you contribute to |
| **Multi-User Leaderboard** | Compare 3+ users side by side with gold/silver/bronze rankings |
| **Historical Trends** | Append stats to a JSON history file, track week-over-week progress |
| **Interactive HTML Report** | Full dashboard with Chart.js charts: activity, languages, hours, files, churn |
| **Exclude Patterns** | `--exclude` regex to skip repos by name |
| **Animated SVG** | CSS animations for bars, donut chart, treemap, and achievement badges |
| **10 Built-in Themes** | dark, light, radical, tokyonight, dracula, nord, catppuccin, ocean, sunset, cyberpunk |
| **Custom Themes** | Define your own with 3 hex colors |
| **Weekly/Monthly Rollups** | Aggregate daily stats into weekly or monthly buckets |
| **Comparison Mode** | Head-to-head stats vs any public GitHub user |
| **Shields.io Badges** | Generate endpoint JSON for dynamic README badges |

## SVG card themes

| Theme | Look |
|-------|------|
| `dark` | Blue on dark gray (default) |
| `light` | Blue on white |
| `radical` | Hot pink + cyan on deep purple |
| `tokyonight` | Soft blue + teal on navy |
| `dracula` | Purple + pink on charcoal |
| `nord` | Ice blue on arctic |
| `catppuccin` | Lavender on mocha |
| `ocean` | Teal + mint on deep navy |
| `sunset` | Orange + gold on violet |
| `cyberpunk` | Neon red + cyan on black |

---

## Add to your GitHub profile (no API, no deployment)

Runs via GitHub Actions. No Vercel, no server. The action generates an SVG every 2 hours and commits it to your profile repo.

### 1. Create a token

1. Go to [github.com/settings/tokens](https://github.com/settings/tokens)
2. Click **Generate new token (classic)**
3. Select scopes: `repo` and `read:user`
4. Copy the token (starts with `ghp_`)

### 2. Add the token to your profile repo

Your profile repo is `github.com/<your-username>/<your-username>`.

1. Go to your profile repo -> **Settings** -> **Secrets and variables** -> **Actions**
2. Click **New repository secret**
3. Name: `GH_PAT`
4. Value: paste your token

### 3. Add the workflow

Create `.github/workflows/update-clc.yml` in your profile repo:

```yaml
name: Update LOC Stats Card

on:
  schedule:
    - cron: "0 */2 * * *"
  workflow_dispatch:

permissions:
  contents: write

jobs:
  update-card:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - run: pip install requests python-dotenv
      - run: curl -sL https://raw.githubusercontent.com/Rudra-Tiwari-codes/CLC/main/daily_loc.py -o daily_loc.py
      - name: Generate SVG card
        env:
          GITHUB_TOKEN: ${{ secrets.GH_PAT }}
        run: python daily_loc.py -d 30 --svg clc-card.svg --theme dark
      - name: Commit and push
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git diff --quiet clc-card.svg 2>/dev/null && echo "No changes" && exit 0
          git add clc-card.svg
          git commit -m "chore: update LOC stats card [skip ci]"
          git push
```

### 4. Add to your README

```markdown
![My Coding Stats](./clc-card.svg)
```

### 5. Push and done

Card auto-updates every 2 hours.

---

## How it works

Uses your GitHub token to pull repos and commits via the REST API. Commit details are cached locally so repeat runs are fast. Stats get broken down by day, language, repo, and file, then rendered however you want (terminal, SVG, HTML, JSON).

## License

[MIT](LICENSE)
