Skip to content

Latest commit

 

History

History
180 lines (133 loc) · 11.9 KB

README.md

File metadata and controls

180 lines (133 loc) · 11.9 KB

codeint: see Software entropy grow before it compounds

CI status GitHub Release npm version License: MIT

Why codeint · How it works · Quick start · Guide · Reference · Programmatic API · Plugins · llms.txt

Note

Early development: codeint is still pre-1.0 and evolving quickly. CLI flags, configuration keys, report shapes, and the WebAssembly Plugin contract may change rapidly before 1.0.

Why codeint

Coding agents write locally valid code very quickly. Each pull request can pass tests and linters while quietly adding copied blocks, redundant branches, deeper functions, unused dependencies, and tangled imports. Over dozens of changes, that structural drag compounds until both humans and agents slow down.

codeint measures Software entropy directly from the shape of your source code so you see it grow before it compounds. It ships with six built-in Language plugins covering TypeScript/JavaScript (including React .jsx/.tsx, Vue, and Svelte <script> blocks), Rust, PHP, Dart, Python, and Go, plus sandboxed WebAssembly Plugins for other languages and custom Metrics.

How it works

Independent Metrics, never one blended score

codeint reports every Metric side by side and never collapses them into one grade or index (ADR 0003). A single score hides regressions when one Metric improves while another worsens.

Four core Metrics are calibrated against pre-2023 human-written repositories:

  • Erosion: share of Function mass (cyclomatic_complexity * sqrt(source_lines)) in functions with cyclomatic complexity over 10, reported with function names.
  • Duplication: share of source lines in exact Clone groups (at least 75 normalized tokens and 14 distinct normalized tokens, catching renamed copy-paste while ignoring import lists and data tables), grouped into Clone families across three or more locations, with opt-in shingle-based near-clone detection.
  • Verbosity: share of source lines in zero-false-positive Flagged lines or exact Clone groups.
  • Import cycles: share of modules in at least one runtime Import cycle.

Additional independent Metrics and structural checks run in the same pass:

  • Cognitive complexity: share of total nesting-weighted cognitive complexity held by functions scoring over 15.
  • Test gap: share of total Production Function mass not executed by tests, read from user-named LCOV or Cobertura XML Coverage reports without running your test suite, listing the heaviest untested functions first (Test gap guide, ADR 0017).
  • Orphan files: Production files unreachable from manifest-declared, program-start, and configured entry_points, classified as unreferenced or test-only.
  • Dependency hygiene: three independent Metrics (unused_dependencies, unlisted_dependencies, and dev_in_production_dependencies) comparing package.json, Cargo.toml, pyproject.toml, composer.json, pubspec.yaml, and go.mod against imported external packages while excluding standard-library built-ins.
  • Architectural import boundaries: named zones, built-in layered and hexagonal presets, public_files encapsulation, directional allow/deny rules, and pre-edit codeint guard <path> checks before a file even exists on disk.

Every file belongs to one Source set (production, test, generated, or vendored), so fixtures and generated code never distort Production ratios. Budgets cap absolute ratios in codeint check, while codeint diff <base> ratchets every pull request against its Git merge-base.

Codebase navigation, Git history, and ownership

Beyond static snapshots, codeint helps humans and coding agents understand how files connect and evolve:

  • codeint trace <from> <to>: find the shortest runtime import paths between two modules.
  • codeint impact <paths...> / --changed <base-ref>: compute the transitive reverse-dependency blast radius, separating Production and Test dependents and listing affected Workspace packages.
  • --package <path>: scope check, diff, impact, and trace to one Workspace package in a monorepo.
  • codeint churn: rank eroded and duplicated files alongside their Git commit churn independently per Metric.
  • codeint coupling: detect pairs of files that repeatedly change together in the same commits and flag whether they share a direct runtime import.
  • CODEOWNERS filtering (--owner <pattern>): filter check and diff Findings to a specific team or owner.

Built for CI and coding agents

  • JSONC configuration: configure codeint in codeint.jsonc or codeint.json with comments and trailing commas (codeint init writes a starter codeint.jsonc).
  • Single-scan multi-format reporting: save codeint check --format json or codeint diff --format json once, then re-render losslessly into text, toon, json, sarif, or markdown with codeint report.
  • Introspection and diagnostics: inspect machine-readable CLI/MCP capabilities with codeint schema, see effective settings with default/file/cli provenance via codeint config --resolved, and verify repository health offline with codeint doctor.
  • First-class MCP integration: run codeint agent status and codeint agent install to register the local stdio MCP server (codeint mcp) for Claude Code, Cursor, and Codex, exposing check, diff, trend, guard, impact, trace, churn, and coupling.

Built for speed and safety

codeint is written in safe Rust (#![forbid(unsafe_code)], ADR 0004) around two clean seams: Language plugins lower source files into a language-neutral Code model, and Metric plugins compute Metrics and Findings over that model. It reads tracked files and commit history directly from Git objects without modifying your working tree, scanning laravel/framework (132k Production lines) in 0.47s and flutter/packages (434k Production lines) in 3.68s on Apple Silicon. External WebAssembly Plugins implement the versioned codeint:plugin@0.3.0 WIT contract with mandatory SHA-256 verification, zero host capabilities, and configurable memory and time caps.

Read docs/guide/philosophy-and-architecture.md for the full architecture diagram and design rationale.

Calibrated Reference ranges

10th to 90th percentile across 20 pre-2023 open-source repositories per language or framework (ADR 0008, ADR 0010, ADR 0011, ADR 0012, ADR 0013, ADR 0014, ADR 0015, ADR 0020, ADR 0021):

Language Erosion Duplication Verbosity Import cycles
TypeScript / JavaScript 35.2% to 60.0% 1.7% to 34.6% 1.8% to 34.7% 0.0% to 30.8%
React (.jsx / .tsx) 10.6% to 54.4% 4.6% to 36.8% 4.7% to 36.8% 0.0% to 14.4%
Vue 2 (.vue) 2.0% to 45.2% 3.6% to 19.2% 3.6% to 19.2% 0.0% to 11.4%
Vue 3 (.vue) 1.9% to 38.8% 2.3% to 34.5% 2.4% to 34.6% 0.0% to 7.7%
Rust 38.0% to 64.2% 5.0% to 32.5% 6.0% to 32.9% 2.1% to 50.6%
PHP 5.5% to 67.7% 4.1% to 29.0% 4.2% to 29.2% 0.0% to 10.7%
Dart 4.7% to 41.9% 7.3% to 25.6% 8.0% to 25.9% 7.3% to 52.4%
Python 14.4% to 62.4% 1.2% to 20.1% 1.4% to 20.4% 0.0% to 32.1%
Go 37.9% to 69.2% 4.4% to 18.1% 4.5% to 18.3% 0.0% to 0.0%

See docs/guide/languages.md for per-language rules and sample repository timings.

Quick start

Install the standalone binary on macOS or Linux, on Windows, or run directly with npx:

curl -fsSL https://github.com/avidianity/codeint/releases/latest/download/install.sh | bash
irm https://github.com/avidianity/codeint/releases/latest/download/install.ps1 | iex
npx codeint check

Run codeint inside any Git repository:

codeint init
codeint check
codeint diff main
codeint guard src/domain/order.ts
codeint doctor
codeint agent install
  • codeint init writes a starter codeint.jsonc with a versioned $schema.
  • codeint check measures the working tree and prints each Metric with its Findings.
  • codeint diff main compares the working tree against the merge-base of main and fails on any Budget failure or Regression.
  • codeint guard src/domain/order.ts checks architectural boundary rules for an existing or planned file path.
  • codeint doctor runs offline diagnostics on Git status, config validity, detected languages, workspaces, and Plugins.
  • codeint agent install registers codeint mcp in detected local coding agents.

Or call codeint programmatically from JavaScript/TypeScript (npm install codeint) or Rust (codeint-cli):

import { check, diff } from "codeint";

const checked = await check();
const prDiff = await diff("main");
use std::path::Path;
use codeint_cli::{CheckOptions, DiffOptions, check, diff};

let checked = check(Path::new("."), &CheckOptions::default())?;
let pr_diff = diff(Path::new("."), "main", &DiffOptions::default())?;

Documentation

Development

You need Rust through rustup (rust-toolchain.toml), Node.js 24 and npm (package.json), and gitleaks plus lychee on your PATH.

npm ci
npx lefthook install
cargo xtask affected-tests

Read CONTRIBUTING.md for the contributor workflow and local setup. Agents and people follow the same repository rules: start with .rules and docs/checks/README.md.

License

MIT