generated from ztimson/template
Compare commits
4 Commits
a24961a55c
...
0.0.3
| Author | SHA1 | Date | |
|---|---|---|---|
| 397c9aeb90 | |||
| 73ad9293ae | |||
| 4175bf363c | |||
| c0281cd57c |
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
@@ -13,9 +13,6 @@ jobs:
|
|||||||
- name: Clone Repository
|
- name: Clone Repository
|
||||||
uses: ztimson/actions/clone@develop
|
uses: ztimson/actions/clone@develop
|
||||||
|
|
||||||
- name: Install & Build
|
|
||||||
run: npm i && npm run build
|
|
||||||
|
|
||||||
- name: Publish Library
|
- name: Publish Library
|
||||||
run: |
|
run: |
|
||||||
if [ "${{github.ref_name}}" = "master" ]; then
|
if [ "${{github.ref_name}}" = "master" ]; then
|
||||||
|
|||||||
2
.github/workflows/review.yml
vendored
2
.github/workflows/review.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
|||||||
git fetch origin ${{ github.event.pull_request.base.ref }}
|
git fetch origin ${{ github.event.pull_request.base.ref }}
|
||||||
|
|
||||||
- name: Run AI Review
|
- name: Run AI Review
|
||||||
run: npx -y @ztimson/ai-agents review
|
run: npx -y @ztimson/ai-agents@latest review
|
||||||
env:
|
env:
|
||||||
AI_HOST: anthropic
|
AI_HOST: anthropic
|
||||||
AI_MODEL: claude-sonnet-4-5
|
AI_MODEL: claude-sonnet-4-5
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<br />
|
<br />
|
||||||
|
|
||||||
<!-- Logo -->
|
<!-- Logo -->
|
||||||
<img src="https://git.zakscode.com/repo-avatars/d2c56ffd0220751c2f4a9f6fc1e8125a9a63aeed452ae4f4ab696c084330faa2" alt="Logo" width="200" height="200">
|
<img src="https://git.zakscode.com/repo-avatars/309c233243bcd1c1e9b3f359ec3f59769bb01b655e8ed7b32587781be4c8b21c" alt="Logo" width="200" height="200">
|
||||||
|
|
||||||
<!-- Title -->
|
<!-- Title -->
|
||||||
### AI Agents
|
### AI Agents
|
||||||
@@ -53,8 +53,11 @@ Automated code agents that uses AI to analyze git diffs and provide inline comme
|
|||||||
</h3>
|
</h3>
|
||||||
</summary>
|
</summary>
|
||||||
|
|
||||||
|
#### Prerequisites
|
||||||
|
- [Node.js](https://nodejs.org/en/download)
|
||||||
|
|
||||||
#### Instructions
|
#### Instructions
|
||||||
1. Run using npx: `npx @ztimson/ai-agents review`
|
1. Run using npx: `npx -y @ztimson/ai-agents@latest review`
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,26 @@ dotenv.config({path: '.env.local', override: true, quiet: true, debug: false});
|
|||||||
const commit = await $`cd ${root} && git log -1 --pretty=format:%H`;
|
const commit = await $`cd ${root} && git log -1 --pretty=format:%H`;
|
||||||
const gitDiff = await $`cd ${root} && git diff ${branch}`;
|
const gitDiff = await $`cd ${root} && git diff ${branch}`;
|
||||||
|
|
||||||
|
if(!gitDiff) {
|
||||||
|
console.warn('No diff found');
|
||||||
|
return process.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
let existingComments = '';
|
||||||
|
if(git && pr) {
|
||||||
|
const res = await fetch(`${git}/api/v1/repos/${owner}/${repo}/pulls/${pr}/reviews`, {
|
||||||
|
headers: {'Authorization': `token ${auth}`}
|
||||||
|
});
|
||||||
|
if(res.ok) {
|
||||||
|
const reviews = await res.json();
|
||||||
|
const allComments = reviews.flatMap(r => r.comments || []);
|
||||||
|
if(allComments.length) {
|
||||||
|
existingComments = '\n\nExisting review comments (DO NOT repeat these):\n' +
|
||||||
|
allComments.map(c => `- ${c.path}:${c.line || c.position}: ${c.body}`).join('\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let options = {ollama: {model, host}};
|
let options = {ollama: {model, host}};
|
||||||
if(host === 'anthropic') options = {anthropic: {model, token}};
|
if(host === 'anthropic') options = {anthropic: {model, token}};
|
||||||
else if(host === 'openai') options = {openAi: {model, token}};
|
else if(host === 'openai') options = {openAi: {model, token}};
|
||||||
@@ -37,7 +57,7 @@ dotenv.config({path: '.env.local', override: true, quiet: true, debug: false});
|
|||||||
...options,
|
...options,
|
||||||
model: [host, model],
|
model: [host, model],
|
||||||
path: process.env['path'] || os.tmpdir(),
|
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 directly related to changes. Ignore formatting recommendations. After making all recommendations, provide one brief bullet-point summary.`,
|
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 directly related to changes. Ignore formatting recommendations. After making all recommendations, provide some concluding remarks about the overall state of the changes.${existingComments}`,
|
||||||
tools: [{
|
tools: [{
|
||||||
name: 'read_file',
|
name: 'read_file',
|
||||||
description: 'Read contents of a file',
|
description: 'Read contents of a file',
|
||||||
@@ -71,11 +91,6 @@ dotenv.config({path: '.env.local', override: true, quiet: true, debug: false});
|
|||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!gitDiff) {
|
|
||||||
console.warn('No diff found');
|
|
||||||
return process.exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
const messages = await ai.language.ask(gitDiff);
|
const messages = await ai.language.ask(gitDiff);
|
||||||
const summary = messages.pop().content;
|
const summary = messages.pop().content;
|
||||||
if(git) {
|
if(git) {
|
||||||
|
|||||||
Reference in New Issue
Block a user