https://github.com/presidio-oss/cor-matrix
Track and analyze AI-generated code retention in your codebase. Measure how much originally AI-generated code survives vs gets modified over time.
https://github.com/presidio-oss/cor-matrix
ai-assistant ai-code-analysis ai-generated-code code-metrics code-origin code-tracking developer-tools development-analytics retention-analysis
Last synced: 10 months ago
JSON representation
Track and analyze AI-generated code retention in your codebase. Measure how much originally AI-generated code survives vs gets modified over time.
- Host: GitHub
- URL: https://github.com/presidio-oss/cor-matrix
- Owner: presidio-oss
- License: mit
- Created: 2025-06-05T14:53:26.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-07-29T13:12:36.000Z (10 months ago)
- Last Synced: 2025-07-29T15:47:01.656Z (10 months ago)
- Topics: ai-assistant, ai-code-analysis, ai-generated-code, code-metrics, code-origin, code-tracking, developer-tools, development-analytics, retention-analysis
- Language: TypeScript
- Homepage: https://npmjs.org/@presidio-dev/cor-matrix
- Size: 236 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# COR-Matrix
**Code Origin Ratio Matrix** - Track and analyze how much AI-generated code survives in your codebase over time.
## What is COR-Matrix?
COR-Matrix helps development teams understand the real-world impact of AI-generated code by tracking what percentage of originally AI-generated code remains unchanged versus modified or removed during development.
**The Problem:** Teams using AI coding assistants don't know if the generated code is actually useful long-term or gets rewritten immediately.
**The Solution:** COR-Matrix captures signatures of AI-generated code as it's written, then analyzes your codebase later to show retention rates and code evolution patterns.
## Quick Start
### 1. Start the API Server
#### Option A: Using Docker Compose (Recommended)
```bash
# Set up environment variables
cp .env.example .env
# Edit .env file with your actual values
# Start the API server with Docker
docker-compose up -d
```
#### Option B: Local Development
```bash
# Install dependencies
bun install
# Set up environment variables
cp .env.example .env
# Edit .env file with your actual values
# Run database migrations
bun run db:push
# Start the API server
bun run dev:api
```
The API will be available at `http://localhost:3000` with documentation at `http://localhost:3000/docs`.
### 2. Track AI-Generated Code (SDK)
Install the client SDK in your project:
```bash
npm install @presidio-dev/cor-matrix
```
Integrate tracking into your development workflow:
```javascript
import { CorMatrix } from "@presidio-dev/cor-matrix";
const corMatrix = new CorMatrix({
appName: "my-app",
baseURL: "http://localhost:3000",
token: "your-workspace-token",
workspaceId: "your-workspace-id",
});
// Track AI-generated code as you write it
corMatrix.addCodeOriginRecord({
code: "console.log('Hello from AI');",
path: "src/index.ts",
language: "typescript",
generatedBy: "copilot",
});
```
### 3. Generate Reports (CLI)
Analyze your codebase to see AI code retention:
```bash
npx @presidio-dev/cor-matrix report \
--workspace-id your-workspace-id \
--project-path /path/to/your/project \
--api-url http://localhost:3000 \
--api-token your-workspace-token
```
Example output:
```
COR-Matrix Report
────────────────────────────────────────────────────────────────
Codebase Path: /path/to/your/project
Report Time: June 1, 2025 at 6:00 PM
Total Lines: 961 (100%)
AI-Written Lines: 40 of 961 (4.16%)
────────────────────────────────────────────────────────────────
```
## Development
```bash
# Database operations
bun run db:generate # Generate migrations
bun run db:push # Apply migrations
bun run db:studio # Open database GUI
# Development
bun run dev:api # Start API server with hot reload
bun run build:client # Build client SDK
bun run build:api # Build API Docker image
```
## Architecture
- **API Server**: Elysia.js REST API with SQLite database
- **SDK**: Node.js library for real-time code tracking
- **CLI**: Command-line tool for codebase analysis
- **Database**: Stores code signatures and workspace data
Built with TypeScript, Bun, Drizzle ORM, and Docker.
## Contributing
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Security
For security concerns, please see our [Security Policy](SECURITY.md).