Added review
All checks were successful
Build and publish / Build Container (push) Successful in 1m1s

This commit is contained in:
2025-12-27 19:53:48 -05:00
parent c27802ca44
commit 5d3e15f0f5
3 changed files with 40 additions and 12 deletions

32
.github/workflows/review.yml vendored Normal file
View File

@@ -0,0 +1,32 @@
name: AI Code Review
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
review:
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Fetch base branch
run: |
git fetch origin ${{ github.event.pull_request.base.ref }}
git branch -r
- name: Run AI Review
uses: docker://git.zakscode.com/zakscode/ai-reporter:latest
env:
AI_HOST: anthropic
AI_MODEL: claude-sonnet-4-5
AI_TOKEN: ${{ secrets.ANTHROPIC_TOKEN }}
GIT_HOST: ${{ github.server_url }}
GIT_OWNER: ${{ github.repository_owner }}
GIT_REPO: ${{ github.event.repository.name }}
GIT_TOKEN: ${{ secrets.ASSISTANT_TOKEN }}
GIT_BRANCH: origin/${{ github.event.pull_request.base.ref }}
PULL_REQUEST: ${{ github.event.pull_request.number }}

View File

@@ -1,7 +1,7 @@
FROM node:22
COPY . /ai
RUN cd /ai && npm ci
RUN cd /ai && npm ci && mkdir -p /github/workspace
WORKDIR /app
ENTRYPOINT ["npx", "--yes", "/ai", "review", "/app"]
WORKDIR /github/workspace
ENTRYPOINT ["npx", "--yes", "/ai", "review", "/github/workspace"]

View File

@@ -9,26 +9,22 @@ dotenv.config();
dotenv.config({path: '.env.local', override: true});
(async () => {
const
const root = process.argv[2] || process.cwd(),
branch = process.env['GIT_BRANCH'] || await $`cd ${root} && git symbolic-ref refs/remotes/origin/HEAD`,
git = process.env['GIT_HOST'],
owner = process.env['GIT_OWNER'],
repo = process.env['GIT_REPO'],
auth = process.env['GIT_TOKEN'],
pr = process.env['PULL_REQUEST'],
root = process.argv[2] || process.cwd(),
host = process.env['AI_HOST'],
model = process.env['AI_MODEL'],
token = process.env['AI_TOKEN'];
const comments = [];
const commit = await $`cd ${root} && git log -1 --pretty=format:%H`;
const target = await $`cd ${root} && git rev-parse HEAD`;
const dest = await $`cd ${root} && git symbolic-ref refs/remotes/origin/HEAD`;
const gitDiff = await $`git diff ${dest} ${target}`;
const markdown = !!git;
const gitDiff = await $`cd ${root} && git diff ${branch}`;
console.log(`Inspecting: ${root} (${commit})\n`);
console.log(`Reviewing: ${root}\n`);
let options = {ollama: {model, host}};
if(host === 'anthropic') options = {anthropic: {model, token}};
@@ -37,7 +33,7 @@ dotenv.config({path: '.env.local', override: true});
...options,
model: [host, model],
path: process.env['path'] || os.tmpdir(),
system: `You are a code reviewer. Analyze the git diff and use the \`recommend\` tool for EACH issue you find. You must call \`recommend\` exactly once for every bug or improvement opportunity. After making all recommendations, provide a summary using 100 words or less in ${markdown ? 'markdown' : 'unstyled text'}.`,
system: `You are a code reviewer. Analyze the git diff and use the \`recommend\` tool for EACH issue you find. You must call \`recommend\` exactly once for every bug or improvement opportunity. After making all recommendations, provide a brief bullet point summary in markdown.`,
tools: [{
name: 'read_file',
description: 'Read contents of a file',