Code Connoisseur is an AI-powered code review agent built for multiple technology stacks, including MEAN/MERN, Java, and Python. It uses state-of-the-art language models (LLMs) to analyze your code changes and provide actionable, stack-specific feedback.
Want to know how Code Connoisseur compares to commercial tools? See our detailed comparison with leading code review tools like CodeRabbit, DeepCode, Codiga, and Bito.
- Context-aware Reviews: Understands your entire codebase, not just the changed files
- Static Code Analysis: Uses ESLint to catch syntax errors and potential bugs
- Dependency Analysis: Identifies files affected by changes
- Test Coverage Estimation: Suggests areas that need testing
- Edge Case Detection: Recommends edge cases to test based on code patterns
- Multiple LLM Support: Use OpenAI's GPT-4 or Anthropic's Claude models
- Memory System: Remembers past interactions to provide more consistent feedback
- Advanced Feedback Loop: Continuously improves through user feedback and analysis
- Few-Shot Learning: Uses examples of successful reviews to improve quality
Install Code Connoisseur globally via npm:
npm install -g code-connoisseurIf you encounter permission errors, you can either:
-
Use sudo (quick but not recommended for security):
sudo npm install -g code-connoisseur
-
Configure npm to use a different directory (recommended):
mkdir -p ~/.npm-global npm config set prefix '~/.npm-global' export PATH=~/.npm-global/bin:$PATH
Add the export line to your .bashrc or .zshrc file to make it permanent.
After installation, the setup wizard will guide you through configuring your API keys. You'll need:
- OpenAI API key from OpenAI
- Anthropic API key from Anthropic
- (Optional) Pinecone API key from Pinecone
You can reconfigure at any time by running:
code-connoisseur setupIf you prefer to install from source:
-
Clone the repository:
git clone https://github.com/Maheshmali1/code-connoisseur cd code-connoisseur -
Install dependencies:
npm install
-
Create a
.envfile in the project directory:cp .env.example .env
-
Add your API keys to the
.envfile:OPENAI_API_KEY=your_openai_key_here ANTHROPIC_API_KEY=your_anthropic_key_here PINECONE_API_KEY=your_pinecone_key_here # Optional -
Make the CLI tool globally available:
npm link
Before you can use Code Connoisseur, you need to index your codebase:
code-connoisseur index
Options (all are optional):
--directory, -d <path>: Path to your project (default: current directory)--index-name, -i <name>: Name for the vector database index (default: code-connoisseur)--extensions, -e <list>: File extensions to index as comma-separated list (default: js,ts,jsx,tsx,py)--exclude, -x <list>: Directories to exclude as comma-separated list (default: node_modules,dist,build,.git)--js-only: Only index JavaScript files (shortcut for -e js,jsx,ts,tsx)--py-only: Only index Python files (shortcut for -e py)--java-only: Only index Java files (shortcut for -e java)
All configuration and index data will be stored in a .code-connoisseur directory within your project:
.code-connoisseur/
├── config.json # Configuration settings
├── feedback.json # User feedback history
├── metadata/ # Additional metadata
└── vectors/ # Vector embeddings for your codebase
To review changes in a file:
code-connoisseur review <path to file/directory>
Options:
--old, -o <path>: Path to the previous version of the file (if not in git)--llm, -l <provider>: LLM provider to use (openai or anthropic)--index-name, -i <name>: Name of the index to use for review--root, -r <dir>: Project root directory for dependency analysis--stack, -s <stack>: Specify the technology stack (MEAN/MERN, Java, Python)--directory, -d: Review an entire directory of files--extensions, -e <list>: File extensions to include when reviewing directories--markdown, -m <file>: Save review to a markdown file (specify output path)--max-files <number>: Maximum number of files to review in a directory (default: 10)--diff: Only show changes in the review (compact mode)--verbose, -v: Show detailed output during the review process
To view feedback statistics and analysis:
code-connoisseur feedback
This will show you statistics about past reviews, common issues, and suggested prompt improvements based on your feedback.
To configure Code Connoisseur:
code-connoisseur configure
This will launch an interactive prompt to set your preferences.
To list all available indexed codebases:
code-connoisseur list
To clean up indexed files:
code-connoisseur clean [options]
Options:
--index-name, -i <name>: Name of the index to remove--all: Remove all indexed data and configuration--confirm: Skip confirmation prompt (defaults to requiring confirmation)
These options can be used with any command:
code-connoisseur [command] [options]
--version: Show the current version of Code Connoisseur--verbose, -v: Enable verbose output with detailed logging--debug-env: Display environment variable information for debugging
- Indexing: Code Connoisseur parses your codebase, splits it into chunks, and stores embeddings in a vector database (Pinecone).
- Diff Analysis: When reviewing, it analyzes the differences between old and new versions of a file.
- Static Analysis: It checks for code quality issues using ESLint.
- Dependency Analysis: It identifies which files depend on the changed file and which files it depends on.
- Test Coverage: It estimates test coverage and identifies untested changes.
- Edge Case Detection: It suggests edge cases to test based on the code patterns.
- Relevant Context: It retrieves relevant context from the codebase based on the changes.
- Enhanced Prompt: It builds a customized prompt based on feedback history and exemplars.
- AI Review: It uses a language model to analyze all the information and generate comprehensive feedback.
- Feedback Collection: User feedback is collected and analyzed to improve future reviews.
- Continuous Learning: The system adapts to feedback by refining its prompts and approach.
Code Connoisseur is built with several components:
-
Code Parser (
src/codeParser.js):- Uses
esprimato parse JavaScript/TypeScript code into AST - Extracts functions, classes, and other structures
- Handles error recovery for parsing issues
- Uses
-
Vector Store (
src/vectorStore.js):- Generates embeddings using OpenAI's text-embedding-ada-002 model
- Stores embeddings in Pinecone for fast retrieval
- Provides semantic search capabilities for finding relevant code
-
Diff Analyzer (
src/diffAnalyzer.js):- Uses the
difflibrary to compare code versions - Identifies added, removed, and modified lines
- Provides detailed statistics about changes
- Detects potential risks (e.g., commented code, console statements)
- Uses the
-
Code Analyzer (
src/codeAnalyzer.js):- Performs static code analysis using ESLint
- Analyzes dependencies using Madge
- Estimates test coverage for changed code
- Suggests edge cases based on code patterns
-
Feedback System (
src/feedbackSystem.js):- Collects and stores user feedback on reviews
- Analyzes feedback to identify common issues
- Suggests prompt improvements based on patterns
- Provides exemplars of good reviews for few-shot learning
-
Code Review Agent (
src/agent.js):- Uses LangChain with OpenAI or Anthropic models
- Integrates all analysis tools into a comprehensive review
- Remembers past reviews through conversation memory
- Adapts to feedback with improved prompts
- Provides comprehensive, actionable feedback
-
CLI Interface (
src/cli.js):- Provides a user-friendly interface with commands for indexing, reviewing, and analysis
- Handles configuration management and API key validation
- Facilitates the feedback loop for continuous improvement
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.