29 Commits

Author SHA1 Message Date
pacnpal
785bb103c6 Update action.js 2025-02-10 17:25:49 -05:00
pacnpal
d45693ae1c Update release.yml 2025-02-10 17:23:06 -05:00
pacnpal
a9173964c2 Update release.yml 2025-02-10 17:22:58 -05:00
github-actions[bot]
acd58d30ee Add built files 2025-02-10 22:09:31 +00:00
pacnpal
d1c6a98994 Update action.js 2025-02-10 17:08:21 -05:00
github-actions[bot]
e6777037d5 Add built files 2025-02-10 21:57:17 +00:00
pacnpal
c6c00d8c95 Update release.yml 2025-02-10 16:56:24 -05:00
pacnpal
45e3331bcb Update release.yml 2025-02-10 16:50:17 -05:00
pacnpal
dd1b18e57a Update release.yml 2025-02-10 16:47:22 -05:00
pacnpal
1b84aff159 Update action.js 2025-02-10 16:18:34 -05:00
pacnpal
5fb151d172 Update release.yml 2025-02-10 16:09:39 -05:00
pacnpal
4e1bd4b9e5 Merge pull request #5 from pacnpal/pacnpal-patch-1
Update README.md
2025-02-10 16:06:21 -05:00
pacnpal
7276f1e2c5 Update README.md 2025-02-10 16:06:09 -05:00
pacnpal
2c57b7a5ba Update release.yml 2025-02-10 16:05:18 -05:00
pacnpal
096a52cda5 Merge pull request #4 from pacnpal/pacnpal-patch-1
Update README.md
2025-02-10 15:11:02 -05:00
pacnpal
0356960aa8 Update README.md 2025-02-10 15:10:43 -05:00
pacnpal
a5bd0e4bcf Update README.md 2025-02-10 15:02:22 -05:00
pacnpal
e49cf9d908 Merge pull request #3 from pacnpal/pacnpal-patch-1
Update README.md
2025-02-10 14:57:39 -05:00
pacnpal
a4b8566177 Update README.md 2025-02-10 14:55:38 -05:00
pacnpal
fc5d87701c Update action.js 2025-02-10 14:52:55 -05:00
pacnpal
eb556a6d23 Update README.md 2025-02-10 13:35:39 -05:00
pacnpal
7e5914e90c Update README.md 2025-02-10 13:28:43 -05:00
pacnpal
6c6cbaba84 Update README.md 2025-02-10 13:28:03 -05:00
pacnpal
9f9953664f Merge pull request #2 from pacnpal/dependabot/npm_and_yarn/npm_and_yarn-2c579f9325 2025-01-21 21:57:04 -05:00
dependabot[bot]
ada4f6b4ed Bump undici in the npm_and_yarn group across 1 directory
Bumps the npm_and_yarn group with 1 update in the / directory: [undici](https://github.com/nodejs/undici).


Updates `undici` from 5.28.4 to 5.28.5
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v5.28.4...v5.28.5)

---
updated-dependencies:
- dependency-name: undici
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-22 00:48:58 +00:00
pacnpal
a5a4083f00 Update README.md 2024-12-24 11:15:26 -05:00
pacnpal
782f8cccd0 Update README.md 2024-12-24 10:58:45 -05:00
pacnpal
6a73dbfff6 Update README.md 2024-12-24 10:56:46 -05:00
pacnpal
52219d4d98 Update README.md 2024-12-24 10:53:19 -05:00
5 changed files with 68 additions and 58 deletions

View File

@@ -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 'claude-code-review[bot]'
git config --global user.email 'claude-code-review[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:

View File

@@ -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

View File

@@ -33,6 +33,8 @@ async function setupGitConfig() {
// Configure git to fetch PR refs // Configure git to fetch PR refs
await exec('git', ['config', '--local', '--add', 'remote.origin.fetch', '+refs/pull/*/head:refs/remotes/origin/pr/*']); await exec('git', ['config', '--local', '--add', 'remote.origin.fetch', '+refs/pull/*/head:refs/remotes/origin/pr/*']);
await exec('git', ['fetch', 'origin']); await exec('git', ['fetch', 'origin']);
await exec('git', ['config', '--global', 'user.name', 'claude-code-review[bot]']);
await exec('git', ['config', '--global', 'user.email', 'claude-code-review[bot]@users.noreply.github.com']);
} }
async function getDiff(baseSha, headSha) { async function getDiff(baseSha, headSha) {
@@ -48,26 +50,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 +77,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 +96,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: [{

46
dist/index.js vendored
View File

@@ -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) => {
@@ -31861,26 +31877,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}`);
} }
@@ -31907,7 +31904,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:
@@ -31924,7 +31923,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: [{
@@ -32022,6 +32021,7 @@ async function run() {
} }
run(); run();
module.exports = __webpack_exports__; module.exports = __webpack_exports__;
/******/ })() /******/ })()
; ;

4
package-lock.json generated
View File

@@ -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"