codecritique 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -114
- package/package.json +10 -9
- package/src/content-retrieval.test.js +775 -0
- package/src/custom-documents.test.js +440 -0
- package/src/feedback-loader.test.js +529 -0
- package/src/llm.test.js +256 -0
- package/src/project-analyzer.test.js +747 -0
- package/src/rag-analyzer.js +12 -0
- package/src/rag-analyzer.test.js +1109 -0
- package/src/rag-review.test.js +317 -0
- package/src/setupTests.js +131 -0
- package/src/zero-shot-classifier-open.test.js +278 -0
- package/src/embeddings/cache-manager.js +0 -364
- package/src/embeddings/constants.js +0 -40
- package/src/embeddings/database.js +0 -921
- package/src/embeddings/errors.js +0 -208
- package/src/embeddings/factory.js +0 -447
- package/src/embeddings/file-processor.js +0 -851
- package/src/embeddings/model-manager.js +0 -337
- package/src/embeddings/similarity-calculator.js +0 -97
- package/src/embeddings/types.js +0 -113
- package/src/pr-history/analyzer.js +0 -579
- package/src/pr-history/bot-detector.js +0 -123
- package/src/pr-history/cli-utils.js +0 -204
- package/src/pr-history/comment-processor.js +0 -549
- package/src/pr-history/database.js +0 -819
- package/src/pr-history/github-client.js +0 -629
- package/src/technology-keywords.json +0 -753
- package/src/utils/command.js +0 -48
- package/src/utils/constants.js +0 -263
- package/src/utils/context-inference.js +0 -364
- package/src/utils/document-detection.js +0 -105
- package/src/utils/file-validation.js +0 -271
- package/src/utils/git.js +0 -232
- package/src/utils/language-detection.js +0 -170
- package/src/utils/logging.js +0 -24
- package/src/utils/markdown.js +0 -132
- package/src/utils/mobilebert-tokenizer.js +0 -141
- package/src/utils/pr-chunking.js +0 -276
- package/src/utils/string-utils.js +0 -28
package/README.md
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
# CodeCritique
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/codecritique)
|
|
4
|
+
[](https://www.npmjs.com/package/codecritique)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://nodejs.org/)
|
|
7
|
+
[](https://github.com/cosmocoder/CodeCritique/actions/workflows/release.yml)
|
|
8
|
+
|
|
9
|
+
**AI-Powered Code Review. Context-Aware. Privacy-First.**
|
|
10
|
+
|
|
11
|
+
A self-hosted code review tool using **RAG (Retrieval-Augmented Generation)** with local embeddings and Anthropic Claude for intelligent, context-aware code analysis. Works with any programming language.
|
|
12
|
+
|
|
13
|
+
[Features](#key-features) • [Installation](#installation) • [Quick Start](#quick-start) • [GitHub Actions](#github-actions-integration) • [Commands](#commands-reference) • [Contributing](#contributing)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## ❌ The Problem
|
|
18
|
+
|
|
19
|
+
Traditional code review tools fall short:
|
|
20
|
+
|
|
21
|
+
- ❌ **Generic static analysis** doesn't understand your codebase's unique patterns
|
|
22
|
+
- ❌ **No historical context** - ignores lessons from past code reviews
|
|
23
|
+
- ❌ **One-size-fits-all** rules that don't adapt to your team's standards
|
|
24
|
+
- ❌ **Limited language support** - often focused on specific tech stacks
|
|
25
|
+
|
|
26
|
+
## ✅ The Solution
|
|
27
|
+
|
|
28
|
+
**CodeCritique** uses RAG to deliver intelligent, context-aware code reviews:
|
|
29
|
+
|
|
30
|
+
- ✅ **Learns your codebase** - embeddings capture your patterns and conventions
|
|
31
|
+
- ✅ **Remembers PR history** - learns from past review comments and decisions
|
|
32
|
+
- ✅ **Custom guidelines** - integrates your team's coding standards
|
|
33
|
+
- ✅ **Any language** - works with JavaScript, Python, Go, Rust, and more
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 🚀 Quick Install
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npx codecritique analyze --file src/app.ts
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or install globally:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install -g codecritique
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
4
50
|
|
|
5
51
|
## Table of Contents
|
|
6
52
|
|
|
@@ -83,9 +129,28 @@ ANTHROPIC_API_KEY=your_key npx codecritique analyze --file app.py
|
|
|
83
129
|
|
|
84
130
|
### Installation Options
|
|
85
131
|
|
|
86
|
-
|
|
132
|
+
#### Option 1: Using npx (Recommended)
|
|
133
|
+
|
|
134
|
+
The easiest way to use CodeCritique - no installation required:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
npx codecritique analyze --file path/to/file.py
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
View the package on npm: [https://www.npmjs.com/package/codecritique](https://www.npmjs.com/package/codecritique)
|
|
141
|
+
|
|
142
|
+
#### Option 2: Global Installation
|
|
143
|
+
|
|
144
|
+
For frequent use, install globally:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
npm install -g codecritique
|
|
148
|
+
codecritique analyze --file path/to/file.py
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
#### Option 3: Run from Source
|
|
87
152
|
|
|
88
|
-
|
|
153
|
+
For development or contributing:
|
|
89
154
|
|
|
90
155
|
1. **Clone the repository**:
|
|
91
156
|
|
|
@@ -140,21 +205,6 @@ For easier integration with non-JavaScript projects, you can use the provided sh
|
|
|
140
205
|
- Validates Node.js v22.0.0+ requirement
|
|
141
206
|
- Provides helpful error messages for missing dependencies
|
|
142
207
|
|
|
143
|
-
#### Option 2: Using npx (Future - Once Published)
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
# This will be available once the tool is published to npm
|
|
147
|
-
npx codecritique analyze --file path/to/file.py
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
#### Option 3: Global Installation (Future - Once Published)
|
|
151
|
-
|
|
152
|
-
```bash
|
|
153
|
-
# This will be available once the tool is published to npm
|
|
154
|
-
npm install -g codecritique
|
|
155
|
-
codecritique analyze --file path/to/file.py
|
|
156
|
-
```
|
|
157
|
-
|
|
158
208
|
## Quick Start
|
|
159
209
|
|
|
160
210
|
Follow this three-step workflow for optimal code review results:
|
|
@@ -1037,108 +1087,26 @@ DEBUG=true codecritique analyze --file app.py
|
|
|
1037
1087
|
codecritique embeddings:generate --concurrency 3
|
|
1038
1088
|
```
|
|
1039
1089
|
|
|
1040
|
-
## Dependencies
|
|
1041
|
-
|
|
1042
|
-
### Core Dependencies
|
|
1043
|
-
|
|
1044
|
-
- **[@anthropic-ai/sdk](https://www.npmjs.com/package/@anthropic-ai/sdk)** `0.55.0` - Anthropic Claude API integration
|
|
1045
|
-
- **[@lancedb/lancedb](https://www.npmjs.com/package/@lancedb/lancedb)** `0.19.0` - Vector database for embeddings
|
|
1046
|
-
- **[fastembed](https://www.npmjs.com/package/fastembed)** `^1.14.4` - Local embedding generation
|
|
1047
|
-
- **[commander](https://www.npmjs.com/package/commander)** `^11.0.0` - CLI framework
|
|
1048
|
-
- **[chalk](https://www.npmjs.com/package/chalk)** `^5.3.0` - Terminal colors
|
|
1049
|
-
- **[glob](https://www.npmjs.com/package/glob)** `^10.3.0` - File pattern matching
|
|
1050
|
-
|
|
1051
|
-
### Optional Dependencies
|
|
1052
|
-
|
|
1053
|
-
- **[@octokit/rest](https://www.npmjs.com/package/@octokit/rest)** `21.1.1` - GitHub API (for PR history analysis)
|
|
1054
|
-
- **[dotenv](https://www.npmjs.com/package/dotenv)** `16.5.0` - Environment variable loading
|
|
1055
|
-
|
|
1056
|
-
### Development Dependencies
|
|
1057
|
-
|
|
1058
|
-
- **[eslint](https://www.npmjs.com/package/eslint)** `9.29.0` - Code linting
|
|
1059
|
-
- **[prettier](https://www.npmjs.com/package/prettier)** `3.5.3` - Code formatting
|
|
1060
|
-
- **[typescript](https://www.npmjs.com/package/typescript)** `5.8.3` - TypeScript support
|
|
1061
|
-
|
|
1062
1090
|
## Contributing
|
|
1063
1091
|
|
|
1064
|
-
We welcome contributions! Please
|
|
1065
|
-
|
|
1066
|
-
### Development Setup
|
|
1067
|
-
|
|
1068
|
-
1. **Clone the repository**:
|
|
1069
|
-
|
|
1070
|
-
```bash
|
|
1071
|
-
git clone https://github.com/cosmocoder/CodeCritique.git
|
|
1072
|
-
cd CodeCritique
|
|
1073
|
-
```
|
|
1074
|
-
|
|
1075
|
-
2. **Install dependencies**:
|
|
1076
|
-
|
|
1077
|
-
```bash
|
|
1078
|
-
npm install
|
|
1079
|
-
```
|
|
1080
|
-
|
|
1081
|
-
3. **Set up environment**:
|
|
1082
|
-
|
|
1083
|
-
```bash
|
|
1084
|
-
cp .env.example .env
|
|
1085
|
-
# Add your API keys to .env
|
|
1086
|
-
```
|
|
1087
|
-
|
|
1088
|
-
4. **Run locally**:
|
|
1089
|
-
```bash
|
|
1090
|
-
node src/index.js analyze --file test-file.js
|
|
1091
|
-
```
|
|
1092
|
-
|
|
1093
|
-
### Code Standards
|
|
1094
|
-
|
|
1095
|
-
- **ESLint**: Follow the configured ESLint rules
|
|
1096
|
-
- **Prettier**: Code is automatically formatted
|
|
1097
|
-
- **TypeScript**: Type definitions for better code quality
|
|
1098
|
-
|
|
1099
|
-
### Testing
|
|
1100
|
-
|
|
1101
|
-
```bash
|
|
1102
|
-
# Run linting
|
|
1103
|
-
npm run lint
|
|
1104
|
-
|
|
1105
|
-
# Run formatting
|
|
1106
|
-
npm run prettier
|
|
1107
|
-
|
|
1108
|
-
# Run tests
|
|
1109
|
-
npm run test
|
|
1110
|
-
|
|
1111
|
-
# Check for unused dependencies
|
|
1112
|
-
npm run knip
|
|
1113
|
-
```
|
|
1114
|
-
|
|
1115
|
-
### Submitting Changes
|
|
1116
|
-
|
|
1117
|
-
1. **Fork the repository**
|
|
1118
|
-
2. **Create a feature branch**: `git checkout -b feature/amazing-feature`
|
|
1119
|
-
3. **Make your changes**
|
|
1120
|
-
4. **Run tests**: `npm run lint && npm run prettier:ci`
|
|
1121
|
-
5. **Commit your changes**: `git commit -m 'Add amazing feature'`
|
|
1122
|
-
6. **Push to the branch**: `git push origin feature/amazing-feature`
|
|
1123
|
-
7. **Open a Pull Request**
|
|
1124
|
-
|
|
1125
|
-
### Areas for Contribution
|
|
1092
|
+
We welcome contributions! Please see our [CONTRIBUTING.md](CONTRIBUTING.md) guide for:
|
|
1126
1093
|
|
|
1127
|
-
-
|
|
1128
|
-
-
|
|
1129
|
-
-
|
|
1130
|
-
-
|
|
1131
|
-
-
|
|
1132
|
-
- **Testing**: Add comprehensive test coverage
|
|
1094
|
+
- Development setup instructions
|
|
1095
|
+
- Code style guidelines
|
|
1096
|
+
- Commit conventions (for semantic versioning)
|
|
1097
|
+
- Testing guidelines
|
|
1098
|
+
- Pull request process
|
|
1133
1099
|
|
|
1134
|
-
|
|
1100
|
+
## Acknowledgements
|
|
1135
1101
|
|
|
1136
|
-
|
|
1102
|
+
This project is built with these amazing technologies:
|
|
1137
1103
|
|
|
1138
|
-
- **
|
|
1139
|
-
- **
|
|
1140
|
-
- **
|
|
1141
|
-
- **
|
|
1104
|
+
- **[FastEmbed](https://github.com/qdrant/fastembed)** - Fast, lightweight embedding generation
|
|
1105
|
+
- **[Hugging Face Transformers.js](https://github.com/huggingface/transformers.js)** - Machine learning for the web
|
|
1106
|
+
- **[LanceDB](https://lancedb.com/)** - High-performance vector database for embeddings
|
|
1107
|
+
- **[Commander.js](https://github.com/tj/commander.js)** - CLI framework for Node.js
|
|
1108
|
+
- **[Octokit](https://github.com/octokit/rest.js)** - GitHub API client for PR history analysis
|
|
1109
|
+
- **[Anthropic Claude](https://www.anthropic.com/)** - LLM powering intelligent code analysis
|
|
1142
1110
|
|
|
1143
1111
|
## License
|
|
1144
1112
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codecritique",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "AI-powered code review tool for any programming language",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"lint:fix": "eslint . --cache --fix",
|
|
20
20
|
"prettier": "prettier --write . --cache --cache-location ./.prettier-cache",
|
|
21
21
|
"prettier:ci": "prettier --check . --cache --cache-location ./.prettier-cache --cache-strategy content",
|
|
22
|
-
"knip": "knip"
|
|
22
|
+
"knip": "knip",
|
|
23
|
+
"create-release": "semantic-release"
|
|
23
24
|
},
|
|
24
25
|
"keywords": [
|
|
25
26
|
"code-review",
|
|
@@ -35,11 +36,7 @@
|
|
|
35
36
|
"linter"
|
|
36
37
|
],
|
|
37
38
|
"files": [
|
|
38
|
-
"src
|
|
39
|
-
"src/**/*.json",
|
|
40
|
-
"!src/**/*.test.js",
|
|
41
|
-
"!src/test-utils/",
|
|
42
|
-
"!src/setupTests.js",
|
|
39
|
+
"src/*.js",
|
|
43
40
|
"README.md",
|
|
44
41
|
"LICENSE"
|
|
45
42
|
],
|
|
@@ -71,6 +68,10 @@
|
|
|
71
68
|
},
|
|
72
69
|
"devDependencies": {
|
|
73
70
|
"@eslint/js": "9.39.1",
|
|
71
|
+
"@semantic-release/commit-analyzer": "13.0.1",
|
|
72
|
+
"@semantic-release/github": "12.0.3",
|
|
73
|
+
"@semantic-release/npm": "13.1.3",
|
|
74
|
+
"@semantic-release/release-notes-generator": "14.1.0",
|
|
74
75
|
"@types/node": "24.9.1",
|
|
75
76
|
"@vitest/coverage-v8": "4.0.16",
|
|
76
77
|
"@vitest/eslint-plugin": "1.3.23",
|
|
@@ -83,11 +84,11 @@
|
|
|
83
84
|
"vitest": "4.0.16"
|
|
84
85
|
},
|
|
85
86
|
"volta": {
|
|
86
|
-
"node": "22.
|
|
87
|
+
"node": "22.14.0",
|
|
87
88
|
"npm": "10.9.2"
|
|
88
89
|
},
|
|
89
90
|
"engines": {
|
|
90
|
-
"node": "22.
|
|
91
|
+
"node": ">=22.14.0",
|
|
91
92
|
"npm": "10.x"
|
|
92
93
|
},
|
|
93
94
|
"engine-strict": true,
|