Skip to content

EhsanAzish80/Devscope

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

94 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Devscope

Universal Codebase Intelligence for CI & Teams

Analyze any repository in seconds. Get a maintainability grade, risk level, onboarding difficulty, and a CI-ready quality gate β€” zero configuration.

CI Status Python 3.9+ License: MIT Tests: 133 passing Coverage: 82% PyPI version Downloads GitHub Action

πŸš€ Install in 10 Seconds

pipx install devscope
devscope scan .

On macOS:

brew install devscope
devscope scan .

Or install from source:

git clone https://github.com/EhsanAzish80/Devscope.git
cd Devscope
uv sync
uv run devscope scan .

That's it. No config files. No setup. Just intelligence.

Try it now:

devscope summary --compact
Devscope: B · Low risk · Easy onboarding · 1.00 tests · 0.06s ⚑

🎯 Why devscope?

Feature devscope cloc tokei
Maintainability grade βœ… A-F scoring ❌ ❌
CI quality gate βœ… Exit codes ❌ ❌
Multi-language repo intelligence βœ… Full context ⚠️ Basic ⚠️ Basic
Shareable PR summaries βœ… Markdown + badges ❌ ❌
Intelligent caching βœ… 10-20x speedup ❌ ❌
Risk & onboarding metrics βœ… Built-in ❌ ❌
Test coverage detection βœ… Automatic ❌ ❌

🌍 Real-World Examples

See devscope analyzing popular open-source projects:

Devscope: A · Low risk · Moderate onboarding · 1.46 tests · 0.71s ⚑
Devscope: B · Low risk · Hard onboarding · 2.80 tests · 1.27s ⚑
Devscope: A · Low risk · Moderate onboarding · 0.98 tests · 0.10s ⚑
Devscope: B · Low risk · Easy onboarding · 1.82 tests · 0.05s ⚑

Benchmarks run on GitHub Actions (2-core Linux VM).

πŸ“Š Want more examples? See the /research directory for detailed analysis reports of popular repositories, including full markdown summaries and scan metadata.


⚑ Blazing Fast

First scan:

$ devscope scan .
βœ“ Analysis complete in 2.45s

Cached scan (same repo):

$ devscope scan .
βœ“ Analysis complete in 0.15s (cache: 100% hit rate, ~2.3s saved)

10-20x faster on large repos. Automatic cache invalidation when files change.


πŸ§ͺ Devscope Analyzing Itself

This repository is continuously analyzed by devscope.

πŸ” Devscope Report

Badge Badge Badge Badge

Repo: Devscope
Files: 53
Lines: 10,639
Languages: Python (53%) Β· Markdown (21%) Β· Shell (11%)

Health: B (85.5)
Risk: Low
Onboarding: Easy

Tests: 0.87 ratio
Last commit: today

Top hotspot: README.md (855 LOC, Very large file (855 LOC), No nearby tests)

⚑ Scan time: 0.07s

This report is automatically updated on every push.


πŸ’‘ Use Cases

  • CI quality gate β€” Fail builds on grade drops (--fail-under B)
  • PR health comment β€” One-line summary in every PR (devscope summary --compact)
  • Client code audit β€” Instant maintainability report for stakeholders
  • Monorepo onboarding β€” Estimate ramp-up time for new engineers

πŸ“ Shareable Summaries (The Viral Feature)

Embed in Your README

devscope summary --badges > HEALTH.md

Output:

## πŸ” Devscope Report

![Maintainability](https://img.shields.io/badge/maintainability-B-green)
![Risk](https://img.shields.io/badge/risk-Low-green)
![Onboarding](https://img.shields.io/badge/onboarding-Easy-blue)

**Health:** B (82.1) Β· **Risk:** Low Β· **Onboarding:** Easy  
**Files:** 1,247 Β· **Lines:** 45,892 Β· **Tests:** 0.78 ratio

⚑ Scan time: 0.82s (cache: 100% hit rate)

PR Comment (GitHub Actions)

- name: Add health check to PR
  run: |
    devscope summary --compact >> $GITHUB_STEP_SUMMARY

Output:
Devscope: B · Low risk · Easy onboarding · 0.78 tests · 0.82s ⚑

JSON for Bots

devscope summary --json | jq '.health'

Perfect for Slack notifications, status pages, or custom integrations.


πŸ“Š Output Examples

Terminal (Default)

╔═══════════════════════════════════════╗
β•‘     devscope v0.1.0                   β•‘
β•‘  Code Intelligence at a glance        β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

πŸ“Š my-project

Repository          my-project
Health Grade        B (82.5)
Risk Level          Low
Onboarding          Easy

Total Files         1,247
Total Lines         45,892

Languages
  Python            45.2%
  TypeScript        32.8%
  JavaScript        12.1%

Tests               0.78 ratio
Top Hotspot         src/analyzer.py (321 LOC)

βœ“ Analysis complete in 0.82s

Compact (for PRs)

Devscope: B · Low risk · Easy onboarding · 0.78 tests · 0.82s ⚑

JSON (for automation)

{
  "health_score": {
    "maintainability_grade": "B",
    "risk_level": "Low",
    "onboarding_difficulty": "Easy",
    "score_breakdown": {
      "overall": 82.5,
      "complexity": 80.2,
      "tests": 78.0,
      "git_activity": 90.0
    }
  },
  "total_files": 1247,
  "total_lines": 45892,
  "test_ratio": 0.78,
  "scan_time": 0.82
}
πŸ“‹ Full JSON Schema
{
  "analysis": {
    "complexity": {
      "avg_file_size": 368.5,
      "deep_nesting_warning": false,
      "largest_files": [
        {"file_path": "src/analyzer.py", "size_bytes": 9856}
      ],
      "max_directory_depth": 3
    },
    "dependencies": [
      {
        "ecosystem": "Python",
        "manifest_file": "pyproject.toml",
        "dependency_count": 8,
        "dependencies": ["click", "rich", "gitpython", "pathspec"]
      }
    ],
    "git_metrics": {
      "is_git_repo": true,
      "commit_count": 42,
      "contributor_count": 2,
      "days_since_last_commit": 0
    },
    "health_score": {
      "maintainability_grade": "B",
      "risk_level": "Low",
      "onboarding_difficulty": "Easy",
      "score_breakdown": {
        "overall": 82.5,
        "complexity": 80.2,
        "structure": 90.0,
        "tests": 78.0,
        "git_activity": 90.0,
        "hotspots": 85.0
      }
    },
    "hotspots": [
      {
        "file_path": "src/analyzer.py",
        "lines_of_code": 321,
        "depth": 2,
        "has_nearby_tests": true,
        "reason": "Large file with high complexity",
        "risk_score": 75.3
      }
    ],
    "languages": {
      "Python": 52.9,
      "Markdown": 17.6,
      "Shell": 11.8
    },
    "test_metrics": {
      "has_tests": true,
      "test_file_count": 8,
      "source_file_count": 12,
      "test_ratio": 0.667
    },
    "cache_stats": {
      "enabled": true,
      "hits": 55,
      "misses": 5,
      "total_files": 60,
      "hit_rate": 91.67,
      "time_saved_estimate": 0.005
    },
    "total_files": 60,
    "total_lines": 3800,
    "scan_time": 0.15
  },
  "devscope_version": "0.1.0",
  "schema_version": "1.0"
}

πŸ€– CI/CD Integration

Quality Gates with Exit Codes

Exit codes:

  • 0 = Analysis passed all thresholds
  • 1 = Runtime error (invalid path, permissions)
  • 2 = Threshold violated (grade/risk/onboarding)

GitHub Actions

- name: Code health check
  run: |
    devscope ci . \
      --fail-under B \
      --max-risk Medium \
      --max-onboarding Moderate

If health drops below B, the job fails with exit code 2.

GitLab CI

analyze:
  script:
    - devscope ci . --fail-under B --json > analysis.json
  artifacts:
    reports:
      codequality: analysis.json

Shell Script

#!/bin/bash
devscope ci . --fail-under C

if [ $? -eq 2 ]; then
  echo "❌ Code quality below threshold"
  exit 1
fi

🎬 GitHub Action (Official)

The easiest way to integrate Devscope into your workflow β€” official GitHub Action with automatic PR comments and quality gates.

View on Marketplace

Quick Start

Add to .github/workflows/devscope.yml:

name: Code Health

on:
  pull_request:
  push:
    branches: [main]

permissions:
  contents: read
  pull-requests: write

jobs:
  health-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      
      - uses: EhsanAzish80/devscope-action@v1
        with:
          fail-under: B
          max-risk: Medium

What you get:

  • βœ… Automatic PR comments with health metrics
  • βœ… Sticky updates (no spam)
  • βœ… CI quality gates with configurable thresholds
  • βœ… Fast caching (5-8s cached runs)
  • βœ… Works on public & private repos

Advanced Usage

Use outputs in other steps:

- uses: EhsanAzish80/devscope-action@v1
  id: devscope

- name: Check critical health
  run: |
    if [ "${{ steps.devscope.outputs.grade }}" == "F" ]; then
      echo "::error::Code health is critical!"
    fi

Analyze specific directory:

- uses: EhsanAzish80/devscope-action@v1
  with:
    path: ./src
    fail-under: B

PR comment preview:

πŸ“Š Devscope Report

Maintainability: 🟒 B
Risk: 🟒 Low
Onboarding: Easy
⚑ 0.82s

Analyze your repo β†’ pipx install devscope

Learn more: devscope-action


πŸ€– PR Health Bot (Drop-in)

Get instant code health in every pull request β€” zero setup, just copy the workflow.

Add this file to your repo: .github/workflows/devscope-pr.yml

name: Devscope PR Health Check

on:
  pull_request:
    types: [opened, synchronize, reopened]

permissions:
  contents: read
  pull-requests: write

jobs:
  devscope-health:
    name: Post Health Summary
    runs-on: ubuntu-latest
    
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0  # Full history for git metrics

      - name: Install Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.12'

      - name: Install pipx
        run: |
          python -m pip install --user pipx
          python -m pipx ensurepath
          echo "$HOME/.local/bin" >> $GITHUB_PATH

      - name: Install devscope
        run: pipx install devscope

      - name: Run Devscope analysis
        id: devscope
        run: |
          set +e  # Don't fail on non-zero exit
          OUTPUT=$(devscope summary --compact 2>&1)
          EXIT_CODE=$?
          
          # Escape output for GitHub Actions
          OUTPUT="${OUTPUT//'%'/'%25'}"
          OUTPUT="${OUTPUT//$'\n'/'%0A'}"
          OUTPUT="${OUTPUT//$'\r'/'%0D'}"
          
          echo "output=$OUTPUT" >> $GITHUB_OUTPUT
          echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
          
          exit 0  # Always succeed job

      - name: Post or update PR comment
        uses: actions/github-script@v7
        with:
          script: |
            const output = `${{ steps.devscope.outputs.output }}`;
            const exitCode = `${{ steps.devscope.outputs.exit_code }}`;
            
            let commentBody;
            if (exitCode === '0') {
              commentBody = `## πŸ” Devscope Health Check\n\n\`\`\`\n${output}\n\`\`\`\n\n---\n*Updated: ${new Date().toUTCString()}*`;
            } else {
              commentBody = `## πŸ” Devscope Health Check\n\n⚠️ **Analysis failed**\n\n<details>\n<summary>Error output</summary>\n\n\`\`\`\n${output}\n\`\`\`\n</details>\n\n---\n*Updated: ${new Date().toUTCString()}*`;
            }
            
            // Find existing Devscope comment
            const { data: comments } = await github.rest.issues.listComments({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
            });
            
            const existingComment = comments.find(comment => 
              comment.user.type === 'Bot' &&
              comment.body.includes('πŸ” Devscope Health Check')
            );
            
            if (existingComment) {
              // Update existing comment
              await github.rest.issues.updateComment({
                owner: context.repo.owner,
                repo: context.repo.repo,
                comment_id: existingComment.id,
                body: commentBody,
              });
              console.log('Updated existing Devscope comment');
            } else {
              // Create new comment
              await github.rest.issues.createComment({
                owner: context.repo.owner,
                repo: context.repo.repo,
                issue_number: context.issue.number,
                body: commentBody,
              });
              console.log('Created new Devscope comment');
            }

What it does:

  1. Runs on every PR (open, update, reopen)
  2. Installs devscope and analyzes your code
  3. Posts a sticky comment that updates automatically on new commits
  4. Fails gracefully if analysis errors
  5. No secrets required β€” works on public repos

Example PR comment:

## πŸ” Devscope Health Check

Devscope: B · Low risk · Easy onboarding · 0.78 tests · 0.82s ⚑

---
Updated: Thu, 13 Feb 2026 14:52:33 GMT

Features:

  • βœ… Sticky comment (updates instead of spamming)
  • βœ… Shows health trend over PR lifetime
  • βœ… Zero configuration
  • βœ… Works on forks (read-only)

πŸ“– Command Reference

devscope scan

Analyze a codebase with beautiful terminal output.

devscope scan                    # Current directory
devscope scan /path/to/project   # Specific path
devscope scan --json             # JSON output
devscope scan --basic            # Fast scan (no intelligence)
devscope scan --no-git           # Skip git detection
devscope scan --no-cache         # Disable caching
devscope scan --clear-cache      # Clear cache before scan

devscope ci

CI-optimized command (always outputs JSON).

devscope ci                      # Current directory
devscope ci --fail-under B       # Fail if grade < B
devscope ci --max-risk High      # Fail if risk > High
devscope ci --max-onboarding Hard   # Fail if onboarding > Hard

devscope summary

Generate shareable summaries.

devscope summary                 # Markdown report
devscope summary --badges        # Include shields.io badges
devscope summary --compact       # One-line summary
devscope summary --json          # JSON with badges

devscope inject

Inject health metrics into README between markers. Auto-updating health blocks!

devscope inject                  # Inject into ./README.md
devscope inject docs/STATUS.md   # Inject into specific file
devscope inject --check          # Check if update needed (exit 2 if yes)
devscope inject --repo ./src     # Analyze different directory

Setup: Add markers to your README:

# My Project

<!-- DEVSCOPE_START -->
<!-- DEVSCOPE_END -->

Result: Health block auto-injected between markers:

<!-- DEVSCOPE_START -->
## πŸ” Devscope Report

![Badge](https://img.shields.io/badge/maintainability-B-green)
![Badge](https://img.shields.io/badge/risk-Low-green)

**Repo:** my-project  
**Files:** 1,247  
**Lines:** 45,892  
**Languages:** Python (45%) Β· TypeScript (33%)

**Health:** B (82.5)  
**Risk:** Low  
**Onboarding:** Easy  

⚑ Scan time: 0.82s
<!-- DEVSCOPE_END -->

CI integration:

- name: Update health block
  run: |
    devscope inject
    if git diff --quiet README.md; then
      echo "No changes"
    else
      git config user.name "devscope-bot"
      git config user.email "bot@devscope"
      git add README.md
      git commit -m "chore: update health metrics [skip ci]"
      git push
    fi

Features:

  • βœ… Deterministic output (no change = no commit)
  • βœ… Automatic badge generation
  • βœ… Custom markers supported
  • βœ… Check mode for CI validation

πŸ† Status & Quality

Metric Value
Tests 133 passing
Coverage 82%
Type checking mypy strict mode
Platforms Linux Β· macOS Β· Windows
Python 3.9+

This project follows rigorous engineering standards:

  • βœ… Full type annotations
  • βœ… Comprehensive test suite
  • βœ… Zero runtime dependencies conflicts
  • βœ… Cross-platform compatibility tested

πŸ—ΊοΈ Roadmap

βœ… Completed

  • Maintainability grading (A-F)
  • Risk & onboarding assessment
  • CI quality gates with exit codes
  • Intelligent caching (10-20x speedup)
  • Shareable markdown summaries
  • Shields.io badge generation
  • Test coverage detection
  • JSON automation API

πŸš€ Next

  • Configuration file (.devscope.yml)
  • Historical trend tracking
  • Team analytics dashboard
  • Security scanning (CVE detection)

πŸ› οΈ Development

Quick Start

git clone https://github.com/EhsanAzish80/Devscope.git
cd Devscope
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync --all-extras
uv run devscope scan

Running Tests

uv run pytest                    # All tests
uv run pytest --cov              # With coverage
uv run pytest tests/test_analyzer.py   # Specific file

Code Quality

uv run ruff format .             # Format
uv run ruff check .              # Lint
uv run mypy src/devscope         # Type check

Project Structure

devscope/
β”œβ”€β”€ src/devscope/
β”‚   β”œβ”€β”€ cli.py          # Command-line interface
β”‚   β”œβ”€β”€ analyzer.py     # Core analysis engine
β”‚   β”œβ”€β”€ models.py       # Type-safe data models
β”‚   β”œβ”€β”€ formatters.py   # Summary & badge generation
β”‚   β”œβ”€β”€ cache.py        # Intelligent caching layer
β”‚   └── utils.py        # Shared utilities
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ test_analyzer.py
β”‚   β”œβ”€β”€ test_cli.py
β”‚   β”œβ”€β”€ test_cache.py
β”‚   β”œβ”€β”€ test_summary.py
β”‚   └── test_ci_thresholds.py
└── pyproject.toml      # Dependencies & config

πŸ—οΈ Architecture

Design principles:

  1. Separation of concerns β€” CLI, analysis, formatting isolated
  2. Type safety β€” Full mypy strict mode compliance
  3. Performance β€” Smart caching with automatic invalidation
  4. Extensibility β€” Plugin-ready analyzer system
  5. User experience β€” Beautiful terminal output with Rich

Core components:

  • Analyzer β€” File system traversal, language detection, metrics calculation
  • Cache Manager β€” File metadata caching with invalidation on change
  • Formatters β€” Output generation (terminal/JSON/markdown/compact)
  • CLI β€” Click-based interface with rich error handling

πŸ“„ License

MIT License - see LICENSE file.


🀝 Contributing

Contributions welcome! Please:

  1. Fork the repo
  2. Create a feature branch (git checkout -b feature/amazing)
  3. Run tests (./scripts/check.sh)
  4. Submit a PR

For major changes, open an issue first.


πŸ™ Acknowledgments

Built with:

  • uv β€” Fast dependency management
  • Rich β€” Beautiful terminal UI
  • Click β€” CLI framework

Inspired by tokei and cloc.


πŸ“ž Support

About

X-ray machine for any repository

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages