mirror of
https://github.com/pacnpal/Claude-code-review.git
synced 2025-12-20 12:11:09 -05:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1c6a98994 | ||
|
|
e6777037d5 | ||
|
|
c6c00d8c95 | ||
|
|
45e3331bcb | ||
|
|
dd1b18e57a | ||
|
|
1b84aff159 | ||
|
|
5fb151d172 | ||
|
|
4e1bd4b9e5 | ||
|
|
7276f1e2c5 | ||
|
|
2c57b7a5ba | ||
|
|
096a52cda5 | ||
|
|
0356960aa8 | ||
|
|
a5bd0e4bcf | ||
|
|
e49cf9d908 | ||
|
|
a4b8566177 | ||
|
|
fc5d87701c | ||
|
|
eb556a6d23 | ||
|
|
7e5914e90c | ||
|
|
6c6cbaba84 | ||
|
|
9f9953664f | ||
|
|
ada4f6b4ed | ||
|
|
a5a4083f00 | ||
|
|
782f8cccd0 | ||
|
|
6a73dbfff6 | ||
|
|
52219d4d98 |
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@@ -25,6 +25,14 @@ jobs:
|
|||||||
- name: Build
|
- name: Build
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
|
- name: Commit built files
|
||||||
|
run: |
|
||||||
|
git config --global user.name 'github-actions[bot]'
|
||||||
|
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
||||||
|
git add -f dist
|
||||||
|
git commit -m 'Add built files'
|
||||||
|
git push origin HEAD:main
|
||||||
|
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
|
|||||||
31
README.md
31
README.md
@@ -1,6 +1,6 @@
|
|||||||
# Claude Code Review Action
|
# Claude Code Review Action
|
||||||
|
|
||||||
A GitHub Action that performs automated code reviews using Claude AI.
|
A GitHub Action that performs automated code reviews using Claude Sonnet 3.5, an AI assistant from Anthropic.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- Analyzes code changes in pull requests
|
- Analyzes code changes in pull requests
|
||||||
@@ -13,29 +13,44 @@ A GitHub Action that performs automated code reviews using Claude AI.
|
|||||||
Add this to your GitHub workflow file (e.g. `.github/workflows/review.yml`):
|
Add this to your GitHub workflow file (e.g. `.github/workflows/review.yml`):
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: Code Review
|
name: Claude Code Review
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
# Run on new/updated PRs
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, reopened, synchronize]
|
types: [opened, reopened, synchronize]
|
||||||
|
|
||||||
|
# Allow manual triggers for existing PRs
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
pr_number:
|
||||||
|
description: 'Pull Request Number'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
review:
|
code-review:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
environment: development_environment
|
||||||
contents: read
|
|
||||||
pull-requests: write
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- uses: your-username/claude-code-review-action@v1
|
- name: Run Claude Review
|
||||||
|
uses: pacnpal/claude-code-review@main
|
||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
anthropic-key: ${{ secrets.ANTHROPIC_API_KEY }}
|
anthropic-key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||||
pr-number: ${{ github.event.pull_request.number }}
|
pr-number: ${{ github.event.pull_request.number || inputs.pr_number }}
|
||||||
```
|
```
|
||||||
|
- Click on "Claude Code Review" Action under Actions tab.
|
||||||
|
- Click "Run Workflow"
|
||||||
|
- Fill in branch and pull request ID and click "Run Workflow"
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
|
|||||||
27
action.js
27
action.js
@@ -48,26 +48,7 @@ async function getDiff(baseSha, headSha) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Filter for relevant files
|
return diffContent;
|
||||||
const lines = diffContent.split('\n');
|
|
||||||
let filtered = '';
|
|
||||||
let keep = false;
|
|
||||||
|
|
||||||
for (const line of lines) {
|
|
||||||
if (line.startsWith('diff --git')) {
|
|
||||||
keep = false;
|
|
||||||
// Check if file type should be included
|
|
||||||
if (line.match(/\.(js|ts|py|cpp|h|java|cs)$/) &&
|
|
||||||
!line.match(/(package-lock\.json|yarn\.lock|\.md|\.json)/)) {
|
|
||||||
keep = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (keep) {
|
|
||||||
filtered += line + '\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return filtered;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`Failed to generate diff: ${error.message}`);
|
throw new Error(`Failed to generate diff: ${error.message}`);
|
||||||
}
|
}
|
||||||
@@ -94,7 +75,9 @@ For each issue found:
|
|||||||
- Provide specific recommendations for fixes
|
- Provide specific recommendations for fixes
|
||||||
- Include code examples where helpful
|
- Include code examples where helpful
|
||||||
|
|
||||||
If no issues are found in a particular area, explicitly state that.
|
- If no issues are found in a particular area, explicitly state that.
|
||||||
|
- If it's a dependency update, evaluate with strict scrutiny the implications of the change.
|
||||||
|
- No matter your findings, give a summary of the pull request.
|
||||||
|
|
||||||
Here is the code diff to review:
|
Here is the code diff to review:
|
||||||
|
|
||||||
@@ -111,7 +94,7 @@ ${diffContent}
|
|||||||
'anthropic-version': '2023-06-01'
|
'anthropic-version': '2023-06-01'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
model: 'claude-3-sonnet-20240229',
|
model: 'claude-3-5-sonnet-20241022',
|
||||||
max_tokens: 4096,
|
max_tokens: 4096,
|
||||||
temperature: 0.7,
|
temperature: 0.7,
|
||||||
messages: [{
|
messages: [{
|
||||||
|
|||||||
23
dist/index.js
vendored
23
dist/index.js
vendored
@@ -15741,6 +15741,14 @@ const { isUint8Array, isArrayBuffer } = __nccwpck_require__(8253)
|
|||||||
const { File: UndiciFile } = __nccwpck_require__(3041)
|
const { File: UndiciFile } = __nccwpck_require__(3041)
|
||||||
const { parseMIMEType, serializeAMimeType } = __nccwpck_require__(4322)
|
const { parseMIMEType, serializeAMimeType } = __nccwpck_require__(4322)
|
||||||
|
|
||||||
|
let random
|
||||||
|
try {
|
||||||
|
const crypto = __nccwpck_require__(7598)
|
||||||
|
random = (max) => crypto.randomInt(0, max)
|
||||||
|
} catch {
|
||||||
|
random = (max) => Math.floor(Math.random(max))
|
||||||
|
}
|
||||||
|
|
||||||
let ReadableStream = globalThis.ReadableStream
|
let ReadableStream = globalThis.ReadableStream
|
||||||
|
|
||||||
/** @type {globalThis['File']} */
|
/** @type {globalThis['File']} */
|
||||||
@@ -15826,7 +15834,7 @@ function extractBody (object, keepalive = false) {
|
|||||||
// Set source to a copy of the bytes held by object.
|
// Set source to a copy of the bytes held by object.
|
||||||
source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength))
|
source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength))
|
||||||
} else if (util.isFormDataLike(object)) {
|
} else if (util.isFormDataLike(object)) {
|
||||||
const boundary = `----formdata-undici-0${`${Math.floor(Math.random() * 1e11)}`.padStart(11, '0')}`
|
const boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, '0')}`
|
||||||
const prefix = `--${boundary}\r\nContent-Disposition: form-data`
|
const prefix = `--${boundary}\r\nContent-Disposition: form-data`
|
||||||
|
|
||||||
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|
||||||
@@ -30011,6 +30019,14 @@ module.exports = require("net");
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 7598:
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
module.exports = require("node:crypto");
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
/***/ 8474:
|
/***/ 8474:
|
||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
@@ -31907,7 +31923,9 @@ For each issue found:
|
|||||||
- Provide specific recommendations for fixes
|
- Provide specific recommendations for fixes
|
||||||
- Include code examples where helpful
|
- Include code examples where helpful
|
||||||
|
|
||||||
If no issues are found in a particular area, explicitly state that.
|
- If no issues are found in a particular area, explicitly state that.
|
||||||
|
- If it's a dependency update, evaluate with strict scrutiny the implications of the change.
|
||||||
|
- No matter your findings, give a summary of the pull request.
|
||||||
|
|
||||||
Here is the code diff to review:
|
Here is the code diff to review:
|
||||||
|
|
||||||
@@ -32022,6 +32040,7 @@ async function run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run();
|
run();
|
||||||
|
|
||||||
module.exports = __webpack_exports__;
|
module.exports = __webpack_exports__;
|
||||||
/******/ })()
|
/******/ })()
|
||||||
;
|
;
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -3241,7 +3241,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici": {
|
"node_modules/undici": {
|
||||||
"version": "5.28.4",
|
"version": "5.28.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.5.tgz",
|
||||||
|
"integrity": "sha512-zICwjrDrcrUE0pyyJc1I2QzBkLM8FINsgOrt6WjA+BgajVq9Nxu2PbFFXUrAggLfDXlZGZBVZYw7WNV5KiBiBA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/busboy": "^2.0.0"
|
"@fastify/busboy": "^2.0.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user