Codect is a free and open-source tool designed to detect whether a piece of code was written by an AI or a human. It supports multiple programming languages and provides detailed insights based on various code features such as entropy, comment ratio, AST complexity, and more.
This monorepo contains three main packages:
- @codect/core: Core detection algorithms and language analysis
- @codect/cli: Beautiful command-line interface with interactive mode
- @codect/api: Fast REST API server built with FastAPI
- Multi-Language Support: Detect AI-generated code in Python and JavaScript
- Entropy & Complexity Analysis: Uses token entropy and AST depth to determine AI-generated patterns
- Comment Ratio Evaluation: Analyzes documentation habits in code
- Function & Loop Detection: Evaluates structure complexity
- Beautiful CLI: Interactive terminal UI with colors and ASCII art
- Fast API: High-performance REST API with FastAPI
- Modular Architecture: Clean separation of concerns with monorepo structure
- Node.js 18+ and npm
- Python 3.8+
- Git
# Clone the repository
git clone https://github.com/GustyCube/Codect.git
cd Codect
# Install dependencies
npm install
npm run build
# Install Python dependencies for the API
cd packages/api
pip install -r requirements.txt
cd ../..
The CLI provides a beautiful terminal interface for code analysis:
# Run interactive mode
npx codect
# Analyze a specific file
npx codect analyze path/to/file.py --detailed
# Get help
npx codect --help
Features:
- Interactive mode with menu navigation
- Beautiful ASCII art logo with gradient colors
- Colored output and progress spinners
- Detailed analysis with feature breakdown
- Support for both file and snippet analysis
Start the API server:
cd packages/api
python main.py
The API will be available at http://localhost:8000
Health Check
curl http://localhost:8000/health
Basic Analysis (/basic
)
curl -X POST "http://localhost:8000/basic" \
-H "Content-Type: application/json" \
-d '{"code": "def add(x, y): return x + y", "language": "python"}'
Detailed Analysis (/premium
)
curl -X POST "http://localhost:8000/premium" \
-H "Content-Type: application/json" \
-d '{"code": "def add(x, y): return x + y", "language": "python"}'
# Run all packages in development mode
npm run dev
# Run tests
npm test
# Lint code
npm run lint
# Build all packages
npm run build
- The code is tokenized, and entropy is measured.
- Comment ratio is calculated to analyze documentation habits.
- AST parsing extracts function, loop, and exception counts.
- The system assigns a score based on heuristic rules.
- If the score exceeds a threshold, the code is flagged as AI-generated.
We welcome contributions! Feel free to:
- Submit issues & feature requests.
- Improve multi-language support.
- Optimize AI detection heuristics.
- Expand API functionality.
Codect is licensed under the GNU General Public v3.0 license. You are free to modify and distribute the project as needed.
For questions or contributions, open an issue on GitHub or reach out to [email protected]
.
Let us know if you have any suggestions! 🚀