codecritique 2.0.1 → 2.0.3
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 +3 -3
- package/package.json +3 -3
- package/src/rag-analyzer.js +7 -2
- package/src/rag-analyzer.test.js +13 -0
- package/src/rag-review.js +12 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/codecritique)
|
|
4
4
|
[](https://www.npmjs.com/package/codecritique)
|
|
5
5
|
[](https://opensource.org/licenses/MIT)
|
|
6
|
-
[](https://nodejs.org/)
|
|
7
7
|
[](https://github.com/cosmocoder/CodeCritique/actions/workflows/release.yml)
|
|
8
8
|
|
|
9
9
|
**AI-Powered Code Review. Context-Aware. Privacy-First.**
|
|
@@ -96,7 +96,7 @@ This RAG-based approach provides more accurate, project-specific code reviews co
|
|
|
96
96
|
|
|
97
97
|
### Prerequisites
|
|
98
98
|
|
|
99
|
-
- **Node.js**
|
|
99
|
+
- **Node.js** 24 or newer
|
|
100
100
|
- **Git** (for diff-based analysis)
|
|
101
101
|
- **Anthropic API key** (for LLM analysis)
|
|
102
102
|
|
|
@@ -199,7 +199,7 @@ For easier integration with non-JavaScript projects, you can use the provided sh
|
|
|
199
199
|
|
|
200
200
|
3. **Environment setup** (the script handles this automatically):
|
|
201
201
|
- Creates/uses `.env` file in your project directory
|
|
202
|
-
- Validates Node.js
|
|
202
|
+
- Validates Node.js 24+ requirement
|
|
203
203
|
- Provides helpful error messages for missing dependencies
|
|
204
204
|
|
|
205
205
|
## Quick Start
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codecritique",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "AI-powered code review tool for any programming language",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -90,8 +90,8 @@
|
|
|
90
90
|
"npm": "11.12.1"
|
|
91
91
|
},
|
|
92
92
|
"engines": {
|
|
93
|
-
"node": ">=24
|
|
94
|
-
"npm": ">=11
|
|
93
|
+
"node": ">=24",
|
|
94
|
+
"npm": ">=11"
|
|
95
95
|
},
|
|
96
96
|
"engine-strict": true,
|
|
97
97
|
"publishConfig": {
|
package/src/rag-analyzer.js
CHANGED
|
@@ -722,7 +722,7 @@ function prepareContextForLLM(filePath, content, language, finalCodeExamples, fi
|
|
|
722
722
|
context: contextSections,
|
|
723
723
|
codeExamples,
|
|
724
724
|
guidelineSnippets,
|
|
725
|
-
customDocs: relevantCustomDocChunks
|
|
725
|
+
customDocs: relevantCustomDocChunks?.length > 0 ? relevantCustomDocChunks : customDocs, // Use relevant chunks if available, fallback to full docs
|
|
726
726
|
feedbackContext: generateFeedbackContext(dismissedPatterns), // Add feedback context for LLM
|
|
727
727
|
projectSummary: projectSummary, // Add project architecture summary
|
|
728
728
|
metadata: {
|
|
@@ -1729,7 +1729,12 @@ async function performHolisticPRAnalysis(options) {
|
|
|
1729
1729
|
items: unifiedContext.prComments.slice(0, 10),
|
|
1730
1730
|
},
|
|
1731
1731
|
],
|
|
1732
|
-
customDocs:
|
|
1732
|
+
customDocs:
|
|
1733
|
+
unifiedContext.customDocChunks?.length > 0
|
|
1734
|
+
? unifiedContext.customDocChunks
|
|
1735
|
+
: options.relevantCustomDocChunks?.length > 0
|
|
1736
|
+
? options.relevantCustomDocChunks
|
|
1737
|
+
: customDocs, // Use chunks only when available, then fall back to full docs
|
|
1733
1738
|
projectSummary: projectSummary, // Add project architecture summary
|
|
1734
1739
|
metadata: {
|
|
1735
1740
|
hasCodeExamples: unifiedContext.codeExamples.length > 0,
|
package/src/rag-analyzer.test.js
CHANGED
|
@@ -762,6 +762,19 @@ describe('rag-analyzer', () => {
|
|
|
762
762
|
expect(result.success).toBe(true);
|
|
763
763
|
});
|
|
764
764
|
|
|
765
|
+
it('should fall back to full custom docs when no relevant chunks are found', async () => {
|
|
766
|
+
mockEmbeddingsSystem.getExistingCustomDocumentChunks.mockResolvedValue([
|
|
767
|
+
{ id: 'existing', content: 'Existing indexed chunk', document_title: 'Indexed Doc', chunk_index: 0 },
|
|
768
|
+
]);
|
|
769
|
+
mockEmbeddingsSystem.findRelevantCustomDocChunks.mockResolvedValue([]);
|
|
770
|
+
|
|
771
|
+
await runAnalysis('/test/file.js', {
|
|
772
|
+
customDocs: [{ content: 'Mandatory internal review rule', document_title: 'Internal Standards' }],
|
|
773
|
+
});
|
|
774
|
+
|
|
775
|
+
expect(llm.sendPromptToClaude).toHaveBeenCalledWith(expect.stringContaining('Mandatory internal review rule'), expect.any(Object));
|
|
776
|
+
});
|
|
777
|
+
|
|
765
778
|
it('should log selected chunks when verbose', async () => {
|
|
766
779
|
mockEmbeddingsSystem.findRelevantCustomDocChunks.mockResolvedValue([
|
|
767
780
|
{ id: 'chunk1', content: 'Guidelines', document_title: 'Guide', chunk_index: 0, similarity: 0.85 },
|
package/src/rag-review.js
CHANGED
|
@@ -230,7 +230,17 @@ async function reviewPullRequestWithCrossFileContext(filesToReview, options = {}
|
|
|
230
230
|
verboseLog(verbose, chalk.gray(`Base branch: ${baseBranch}, Target branch: ${targetBranch}`));
|
|
231
231
|
|
|
232
232
|
const prFiles = [];
|
|
233
|
-
|
|
233
|
+
if (options.preloadedPRFiles?.length > 0) {
|
|
234
|
+
prFiles.push(
|
|
235
|
+
...options.preloadedPRFiles.map((file) => ({
|
|
236
|
+
...file,
|
|
237
|
+
baseBranch: file.baseBranch || baseBranch,
|
|
238
|
+
targetBranch: file.targetBranch || targetBranch,
|
|
239
|
+
}))
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
for (const filePath of options.preloadedPRFiles?.length > 0 ? [] : filesToReview) {
|
|
234
244
|
try {
|
|
235
245
|
// Check if the file should be processed before fetching its content from git
|
|
236
246
|
if (!shouldProcessFile(filePath, '', options)) {
|
|
@@ -596,6 +606,7 @@ async function reviewPRChunk(chunk, sharedContext, options, chunkNumber, totalCh
|
|
|
596
606
|
|
|
597
607
|
// Skip chunking decision for chunk reviews to prevent infinite recursion
|
|
598
608
|
const skipChunkingOptions = { ...chunkOptions, skipChunking: true };
|
|
609
|
+
skipChunkingOptions.preloadedPRFiles = chunk.files;
|
|
599
610
|
|
|
600
611
|
return await reviewPullRequestWithCrossFileContext(chunkFilePaths, skipChunkingOptions);
|
|
601
612
|
}
|