EngiScope (sem-cli) — Software Engineering Metrics & Intelligence CLI
Course: ISWE402L – Software Metrics
Product: Software Engineering Metrics Ingestion, Analysis, and Decision Support Platform
PyPI Package:engiscope| CLI Command:sem
Interface: Terminal-based, Unicode TUI inspired by Claude Code
Provider: Google Gemini API (optional, offline-first fallback)
1. Product Overview
sem-cli (distributed as engiscope on PyPI) transforms Git repositories into an evidence-grounded software engineering analytics environment directly from your terminal. It measures source code, mines Git history, audits quality and security, calculates empirical distributions and correlations, ranks engineering hotspots, and optionally provides Gemini AI-powered business and architectural insights.
Core Principles
- Local-first: Runs entirely on the user's workstation without requiring cloud databases, Docker, or Redis.
- Metrics before AI: Numeric measurements originate from deterministic static analysis and Git mining algorithms. AI is an optional interpretation layer, not a dependency for calculating metrics.
- Evidence-backed: Every finding and hotspot links to exact files, line numbers, commits, and formula derivations.
- Reproducible: Measurements are pinned to exact 40-character Git commit SHAs and recorded in local SQLite database snapshots.
- Privacy & Security: Full source code is never sent to Gemini by default; sensitive tokens and credentials are automatically redacted.
📖 Deep Dive Documentation: For complete architectural diagrams, mathematical metric formulations, AST parsers, and command-by-command internal execution flows, see the Technical Implementation Guide.
2. Installation & Quickstart
Install directly from PyPI via pip:
pip install engiscope
Verify your installation:
# Check version and doctor diagnostics
sem --version
sem doctor
(For development or contributing from source: pip install -e ".[dev]")
3. Architecture & Design
engiscope (sem-cli)
├── CLI Layer (Typer, Rich, interactive TUI, Claude Code styling)
├── Services Layer (Analysis orchestration, history mining, reports, AI)
├── Ingestion Engine (Git client, clone manager, revision resolver, inventory)
├── Analysis Engine (Radon, Lizard, AST structural analyzers, secrets & deps)
├── Metrics Catalogue (Product size, complexity, CK OO suite, process, quality)
├── Analytics Layer (Descriptive statistics, IQR outliers, correlations, hotspots, risk)
└── Persistence Layer (SQLite transactional snapshots, runs, comparisons)
4. Complete Software Metrics Catalogue
| Category | Metric | Scope | Unit | Definition & Implementation |
|---|---|---|---|---|
| Product & Size | Physical LOC (loc) |
File, Repo | Lines | Total physical lines in source files |
Source Lines (sloc) |
File, Repo | Lines | Executable and declarative lines excluding blanks & comments | |
Comment Density (comment_density) |
File | Ratio | Ratio of comment lines to source lines | |
| File & Function Count | Repo | Count | Recognized files, classes, and callable functions | |
Test-to-Source Ratio (test_to_source_ratio) |
Repo | Ratio | Test SLOC divided by production source SLOC | |
| Complexity | Cyclomatic Complexity (cyclomatic_complexity) |
Function, File | Count | Linearly independent control-flow paths (Radon / Lizard) |
Halstead Volume (halstead_volume) |
File | Bits | $V = N \times \log_2(\eta)$ derived from operators/operands | |
Halstead Effort (halstead_effort) |
File | Effort | $E = D \times V$ | |
Maintainability Index (maintainability_index) |
File, Repo | Score | SEI/Radon formula scaled to [0, 100] | |
| Complexity Distribution Bands | Repo | Bands | Low (1-5), Moderate (6-10), High (11-20), Very High (21+) | |
| Structural & CK | Weighted Methods per Class (wmc) |
Class, Repo | Count | Sum of method complexities in each class |
Depth of Inheritance Tree (dit) |
Class | Levels | Max inheritance levels from base object | |
Number of Children (noc) |
Class | Count | Immediate subclasses defined in repository | |
Coupling Between Objects (cbo) |
Class, Repo | Count | External class and type references | |
Lack of Cohesion (lcom4) |
Class, Repo | Components | Connected components in method-field access graph | |
| Fan-In & Fan-Out | File | Count | Internal module dependencies and callers | |
Circular Dependencies (circular_dependency_count) |
Repo | Cycles | Import cycles detected via graph cycle traversal | |
| Process & Churn | Commit Frequency & Count | Repo | Commits | Commits analyzed in history window |
| Contributor Count | Repo | Authors | Distinct authors normalized by email identity | |
Code Churn (churn, total_churn) |
File, Repo | Lines | Added lines + deleted lines across commits | |
Change Concentration Gini (churn_gini_concentration) |
Repo | Gini | Gini inequality index of file churn (0=equal, 1=concentrated) | |
| Quality & Security | Code Smells (code_smell_count) |
Repo | Count | Long Method, God Class, Deep Nesting, Long Params |
| Hardcoded Secrets | File | Findings | AWS keys, Private keys, JWT tokens, high-entropy strings | |
| Security Patterns | File | Findings | Dynamic eval(), shell=True, SQL injection, weak hashes |
|
| Dependency Manifest Risks | Repo | Findings | Unpinned dependencies (*, latest) in manifests |
5. Hotspot Prioritization Model
To prioritize technical debt without pretending to predict defects without training data, sem-cli computes:
$$H_f = C_f \times N_f$$
Where:
- $C_f$ is min-max normalized maximum cyclomatic complexity for file $f \in [0.0, 1.0]$.
- $N_f$ is min-max normalized historical change frequency for file $f \in [0.0, 1.0]$.
- $H_f$ is a transparent prioritization score highlighting modules that combine high structural complexity with frequent churn.
6. CLI Command Reference
Interactive Workspace
# Launch interactive terminal TUI
sem
Ingestion & Analysis
# Analyze local repository
sem analyze .
# Analyze remote Git repository URL
sem analyze https://github.com/owner/repository.git
# Analyze specific branch, tag, or commit revision
sem analyze https://github.com/owner/repository.git --ref main
# Limit history depth and select profile
sem analyze . --history-depth 500 --profile full
# Provide optional business context for AI interpretation
sem analyze . --business-context "Payment gateway and billing engine"
Focused Exploration
# Explore software metrics catalogue
sem metrics .
# Rank complexity and churn hotspots
sem hotspots . --limit 15
# Mine Git history, contributors, and churn concentration
sem history . --depth 200
# Run security and secret audit
sem security .
# Run descriptive statistics and empirical correlations
sem stats .
# Compare two analysis revisions or stored snapshots
sem compare . --from v1.0.0 --to v1.1.0
sem compare --run-a <RUN_ID_1> --run-b <RUN_ID_2>
# Ask Google Gemini evidence-grounded questions
sem ask . "Which modules present the highest maintenance risk and why?"
# Generate and export reports
sem report . --format markdown --output REPORT.md
sem export . --format json --output report.json
sem export . --format csv --output metrics.csv
# List past analysis runs
sem runs
# System diagnostics
sem doctor
# Initialize user configuration
sem init
7. Exit Codes
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Unexpected internal error |
2 |
Invalid command or arguments |
3 |
Git clone or ref resolution failed |
4 |
Core analysis failed |
5 |
Persistence failure |
6 |
Security or configuration policy blocked execution |
7 |
Partial analysis (warnings/non-fatal stages recorded) |
8. Gemini AI Integration & Guardrails
- Configured via environment variable:
export GEMINI_API_KEY="your-api-key". - Offline by Default: Complete metrics, hotspots, statistics, and reports operate offline without an API key.
- Minimized Evidence Payload: Only structured metric aggregates, hotspot rankings, and findings are sent to Gemini. Full source code is never uploaded by default.
- Guardrails: AI is instructed never to invent metrics, never to claim vulnerabilities without supporting evidence, and to label operational implications as hypotheses.
Metadata
Release files for engiscope 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| engiscope-0.1.0.tar.gz | 59.0 kB | With provenance | Details for engiscope-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| engiscope-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for engiscope-0.1.0-py3-none-any.whl |
Total release size: 133.8 kB
Release files / engiscope-0.1.0.tar.gz
| Download URL | engiscope-0.1.0.tar.gz |
|---|---|
| Size | 59.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
95a350750546ca7126815c48d1d3e7c02bf4b50d0e850823ecbca0d4ee0de37f
|
|
BLAKE2b-256 checksum How to use checksums |
eb653c45cee36e436186a8f66e6afbd11accfa387cd4c00d829e1c60faaf0d02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logRelease files / engiscope-0.1.0-py3-none-any.whl
| Download URL | engiscope-0.1.0-py3-none-any.whl |
|---|---|
| Size | 74.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2692159253adf2822aa27feee0ce8f24442fbf6f80eef819664d26ae3986be81
|
|
BLAKE2b-256 checksum How to use checksums |
f9f7c07c0fc5c28fb62a46bb2b0002bd41e6340ed70c3898b440bef03cd3f9ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logSecurity for engiscope 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for engiscope-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.