Skip to content

AdeshDeshmukh/cortex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

22 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  Cortex

AI code reviewer that learns from your preferences through reinforcement learning.

Go Version License Tests

Cortex is a privacy-first code reviewer that runs entirely on your machine. Unlike cloud-based tools, it learns YOUR coding style through reinforcement learning and gets smarter with every commit.


โœจ Features

  • ๐Ÿ”’ Privacy-First: All analysis happens locally, code never leaves your machine
  • ๐Ÿง  Adaptive Learning: Uses RL to learn from your accept/reject decisions
  • โšก Fast: Sub-2-second reviews with quantized local models
  • ๐ŸŽฏ Context-Aware: Understands your project structure and patterns
  • ๐Ÿ› ๏ธ Git Integration: Seamlessly works with your existing workflow
  • ๐Ÿ“Š Multi-Language: Supports Go, Python, JavaScript, TypeScript, and more

๐Ÿš€ Quick Start

Installation

# Clone repository
git clone https://github.com/AdeshDeshmukh/cortex.git
cd cortex

# Build
make build

# Install system-wide (optional)
make install

Usage

# Navigate to your project
cd ~/projects/myapp

# Install git hook
cortex install

# Make code changes
echo "func test() {}" >> main.go
git add main.go

# Commit (Cortex reviews automatically)
git commit -m "Add test function"

Output:

๐Ÿง  Cortex Review

๐Ÿ“Š Summary:
   Files changed:  1
   Lines added:    +1
   Lines removed:  -0
   Languages:      go (1)

๐Ÿ“ Files:
   1. main.go (go)
      +1 -0 lines

โณ Analysis pipeline:
   โœ… Diff parsing complete
   โน๏ธ  Static analysis (coming soon)
   โน๏ธ  LLM suggestions (coming soon)

๐Ÿ“– Commands

Command Description
cortex install Install pre-commit hook in current repo
cortex install --force Overwrite existing hook
cortex install --uninstall Remove hook
cortex review Manually review staged changes
cortex review --hook Run in hook mode (internal)
cortex --help Show all commands

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚           USER COMMITS CODE                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
               โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         GIT PRE-COMMIT HOOK                  โ”‚
โ”‚  Triggers: cortex review --hook              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
               โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         DIFF PARSER (Go)                     โ”‚
โ”‚  Converts git diff โ†’ structured data         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
               โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         ANALYZER PIPELINE                    โ”‚
โ”‚  1. Static analysis (regex, AST)             โ”‚
โ”‚  2. LLM inference (local model)              โ”‚
โ”‚  3. Ranking (RL policy)                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
               โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         INTERACTIVE UI                       โ”‚
โ”‚  User accepts/rejects suggestions            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
               โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         FEEDBACK LOOP (Python)               โ”‚
โ”‚  Trains model on user preferences            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ Development

Prerequisites

  • Go 1.21+
  • Git
  • Python 3.10+ (for ML features)

Setup

# Clone repo
git clone https://github.com/AdeshDeshmukh/cortex.git
cd cortex

# Install dependencies
go mod download

# Run tests
make test

# Build
make build

# Run locally
./cortex --help

Testing

# Run all tests
make test

# Run with coverage
make coverage

# Run specific package
go test ./internal/git/

๐Ÿ“ Project Structure

cortex/
โ”œโ”€โ”€ cmd/cortex/              # CLI entry point
โ”‚   โ”œโ”€โ”€ main.go
โ”‚   โ””โ”€โ”€ commands/            # Cobra commands
โ”‚       โ”œโ”€โ”€ root.go
โ”‚       โ”œโ”€โ”€ install.go
โ”‚       โ””โ”€โ”€ review.go
โ”œโ”€โ”€ internal/                # Private application code
โ”‚   โ””โ”€โ”€ git/                 # Git integration
โ”‚       โ”œโ”€โ”€ hooks.go         # Hook management
โ”‚       โ”œโ”€โ”€ diff.go          # Diff parsing
โ”‚       โ””โ”€โ”€ *_test.go        # Tests
โ”œโ”€โ”€ pkg/                     # Public libraries
โ”‚   โ””โ”€โ”€ types/               # Type definitions
โ”‚       โ””โ”€โ”€ types.go
โ”œโ”€โ”€ go.mod                   # Go dependencies
โ”œโ”€โ”€ Makefile                 # Build automation
โ””โ”€โ”€ README.md                # This file

๐ŸŽฏ Roadmap

โœ… Phase 1: Foundation (Current)

  • Git hook installation
  • Diff parsing
  • CLI framework
  • Test infrastructure

๐Ÿšง Phase 2: Intelligence (In Progress)

  • Static code analysis
  • LLM integration (local inference)
  • Prompt engineering
  • Suggestion generation

๐Ÿ“… Phase 3: Learning (Planned)

  • Feedback collection system
  • SQLite storage
  • RL training pipeline (DPO)
  • Model personalization

๐Ÿ”ฎ Phase 4: Advanced (Future)

  • Multi-language support expansion
  • IDE integration (VS Code, IntelliJ)
  • Team-wide model sharing
  • Custom rule definitions

๐Ÿค Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Commit Convention

We follow Conventional Commits:

feat: New feature
fix: Bug fix
docs: Documentation changes
test: Test additions/changes
refactor: Code refactoring
chore: Maintenance tasks

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • Built with Cobra for CLI
  • Inspired by first-principles thinking
  • Part of ongoing learning journey in AI/ML systems

๐Ÿ“ฌ Contact

Adesh Deshmukh

โญ If you find this project useful, please consider giving it a star! // test hook

About

AI code reviewer with reinforcement learning - learns from your preferences..!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors