CodeDNA is the first Deterministic Capture-at-Generation platform. It cryptographically tags AI-generated code blocks at the exact moment of insertion, tracking their complexity-weighted churn across commits to surface hidden "Shadow AI Debt."
This repository contains the Core Python Capture Engine. View the Next.js Frontend Dashboard Repository Here: https://github.com/MRehan516/codedna-frontend
CodeDNA operates locally on the developer's machine with zero IDE extensions required, utilizing a behavioral heuristic pipeline:
- Capture Layer (watcher.py): Uses watchdog to monitor the file system. It extracts diffs on file modification and evaluates velocity, clipboard cross-referencing, and structural density to flag AI-generated insertions.
- Buffer Layer (db.py): Hashes the detected block (SHA-256), calculates its cyclomatic complexity using AST parsing (radon), and writes the event to a local, offline-first SQLite database (.codedna/events.db).
- Sync Layer (ingestor.py): A background worker that flushes pending events to a Supabase PostgreSQL instance for real-time WebSocket broadcasting to the frontend dashboard.
- Python 3.10+
- A Supabase project (for telemetry storage)
git clone https://github.com/MRehan516/codedna-core.git cd codedna-core
python -m venv .venv source .venv/bin/activate (On Windows use: .venv\Scripts\activate)
pip install -r requirements.txt
Copy .env.example to .env and add your Supabase credentials: SUPABASE_URL=https://your-project-id.supabase.co SUPABASE_ANON_KEY=your-anon-key CODEDNA_WATCH_DIR=.
You need two terminal windows running simultaneously:
python -m capture.watcher
python -m capture.ingestor
(Optional) Seed the database with 30 days of realistic demo telemetry: python seed_demo.py
CodeDNA includes a Git hook (hooks/pre-commit) that intercepts commits, reads unsynced events from the local SQLite buffer, and writes a cryptographic .codedna/manifest.json sidecar file into the commit. This ensures every AI insertion is permanently anchored to your git history.