8 Commits

Author SHA1 Message Date
1ab97c2676 Merge pull request 'review-labels' (#14) from review-labels into master
All checks were successful
Publish Library / Build NPM Project (push) Successful in 8s
Publish Library / Tag Version (push) Successful in 7s
Reviewed-on: #14
2026-01-14 14:06:21 -05:00
7447204351 Fixed more logic checks
Some checks failed
Publish Library / Build NPM Project (push) Successful in 4s
Code review / review (pull_request) Has been cancelled
Publish Library / Tag Version (push) Successful in 6s
2026-01-14 14:05:41 -05:00
3b01e1bfc1 Fixed label condition check 💀
All checks were successful
Publish Library / Build NPM Project (push) Successful in 9s
Publish Library / Tag Version (push) Successful in 23s
Code review / review (pull_request) Successful in 49s
2026-01-14 13:51:41 -05:00
1460c3a0ae Added PR info as context to AI
All checks were successful
Publish Library / Build NPM Project (push) Successful in 3s
Publish Library / Tag Version (push) Successful in 5s
Code review / review (pull_request) Successful in 46s
2026-01-14 13:44:31 -05:00
ebc3da8605 Merge branch 'master' of git.zakscode.com:ztimson/ai-agents into review-labels
All checks were successful
Publish Library / Build NPM Project (push) Successful in 3s
Publish Library / Tag Version (push) Successful in 5s
2026-01-14 13:39:50 -05:00
677f84c97a Added label to enable review bot on PRs
All checks were successful
Publish Library / Build NPM Project (push) Successful in 3s
Publish Library / Tag Version (push) Successful in 5s
2026-01-14 13:38:20 -05:00
f543e08e36 Merge pull request 'Added configurable labels to ticket refiner' (#13) from ticket-duplicates into master
All checks were successful
Publish Library / Build NPM Project (push) Successful in 8s
Publish Library / Tag Version (push) Successful in 5s
Reviewed-on: #13
2026-01-14 13:22:33 -05:00
5b9f8e0e13 Fixed minor bugs and typos
All checks were successful
Code review / review (pull_request) Successful in 51s
Publish Library / Build NPM Project (push) Successful in 4s
Publish Library / Tag Version (push) Successful in 5s
2026-01-14 13:14:03 -05:00
6 changed files with 33 additions and 13 deletions

View File

@@ -9,7 +9,5 @@
## Checklist ## Checklist
<!-- Complete after creating PR --> <!-- Complete after creating PR -->
- [ ] Linked issues - [ ] Reviewed changes (or use `Review/AI` label)
- [ ] Reviewed changes
- [ ] Updated comments/documentation - [ ] Updated comments/documentation

View File

@@ -2,7 +2,7 @@ name: Code review
on: on:
pull_request: pull_request:
types: [opened, synchronize, reopened] types: [opened, synchronize, reopened, labeled]
jobs: jobs:
review: review:

View File

@@ -3,6 +3,7 @@ name: Ticket refinement
on: on:
issues: issues:
types: [labeled] types: [labeled]
jobs: jobs:
format: format:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ztimson/ai-agents", "name": "@ztimson/ai-agents",
"version": "0.1.1", "version": "0.1.2",
"description": "AI agents", "description": "AI agents",
"keywords": ["ai", "review"], "keywords": ["ai", "review"],
"author": "ztimson", "author": "ztimson",

View File

@@ -42,7 +42,7 @@ dotenv.config({path: '.env.local', override: true, quiet: true, debug: false});
} }
// Gather readme & template // Gather readme & template
let title = '', type = '', labels = [], readme = '', readmeP = path.join(process.cwd(), 'README.md'); let title = '', labels = [], readme = '', readmeP = path.join(process.cwd(), 'README.md');
if(fs.existsSync(readmeP)) readme = fs.readFileSync(readmeP, 'utf-8'); if(fs.existsSync(readmeP)) readme = fs.readFileSync(readmeP, 'utf-8');
const template = p ? fs.readFileSync(p, 'utf-8') : `## Description const template = p ? fs.readFileSync(p, 'utf-8') : `## Description
@@ -105,7 +105,7 @@ Implementation details, constraints, dependencies, design decisions
args: {label: {type: 'string', description: 'Label name', required: true}}, args: {label: {type: 'string', description: 'Label name', required: true}},
fn: async (args) => { fn: async (args) => {
labels.push(args.label); labels.push(args.label);
fetch(`${git}/api/v1/repos/${owner}/${repo}/issues/${ticket}/labels`, { return await fetch(`${git}/api/v1/repos/${owner}/${repo}/issues/${ticket}/labels`, {
method: 'POST', method: 'POST',
headers: {'Authorization': `token ${auth}`, 'Content-Type': 'application/json'}, headers: {'Authorization': `token ${auth}`, 'Content-Type': 'application/json'},
body: `{"labels":["${args.label}"]}` body: `{"labels":["${args.label}"]}`
@@ -116,11 +116,11 @@ Implementation details, constraints, dependencies, design decisions
**MANDATORY STEPS:** **MANDATORY STEPS:**
1. Call \`title\` tool EXACTLY ONCE in format: "[Module] - [Verb] [subject]" (example: Storage - fix file uploads) 1. Call \`title\` tool EXACTLY ONCE in format: "[Module] - [Verb] [subject]" (example: Storage - fix file uploads)
2. Identify one label from each group which best applies to the ticket: ${labelsReq.replace(',', ', ')} 2. Identify one label from each group which best applies to the ticket: ${labelsReq.replaceAll(',', ', ')}
3. Call the \`add_label\` tool ONCE FOR EVERY LABEL identified in the previous step 3. Call the \`add_label\` tool ONCE FOR EVERY LABEL identified in the previous step
4. Filter the following labels to any that apply to this ticket: ${labelsOpt.replace(',', ', ')} 4. Filter the following labels to any that apply to this ticket: ${labelsOpt.replaceAll(',', ', ')}
5. Call the \`add_label\` tool ONCE FOR EVERY LABEL identified in the previous step 5. Call the \`add_label\` tool ONCE FOR EVERY LABEL identified in the previous step
6. Output the new ticket description in formated markdown matching the following rules: 6. Output the new ticket description in formatted markdown matching the following rules:
**TEMPLATE RULES:** **TEMPLATE RULES:**
- Use ## headers (match template exactly) - Use ## headers (match template exactly)
@@ -181,8 +181,9 @@ Output ONLY markdown. No explanations, labels, or extra formatting.`});
const hasDuplicates = (await ai.language.ask(`ID: ${issueData.id}\nTitle: ${title}\n\`\`\`markdown\n${body}\n\`\`\``, { const hasDuplicates = (await ai.language.ask(`ID: ${issueData.id}\nTitle: ${title}\n\`\`\`markdown\n${body}\n\`\`\``, {
system: `Your job is to identify duplicates. Respond ONLY with the duplicate's ID number or "NONE" if no match exists\n\n${dupes}` system: `Your job is to identify duplicates. Respond ONLY with the duplicate's ID number or "NONE" if no match exists\n\n${dupes}`
}))?.pop()?.content; }))?.pop()?.content;
// Handle duplicates // Handle duplicates
if(hasDuplicates && hasDuplicates !== 'NONE' && (dupeId = dupeIds.find(id => id === hasDuplicates.trim()))) { if(hasDuplicates && !hasDuplicates.toUpperCase().includes('NONE') && (dupeId = dupeIds.find(id => id == hasDuplicates.trim())) != null && dupeId != issueData.id) {
await fetch(`${git}/api/v1/repos/${owner}/${repo}/issues/${ticket}/comments`, { await fetch(`${git}/api/v1/repos/${owner}/${repo}/issues/${ticket}/comments`, {
method: 'POST', method: 'POST',
headers: {'Authorization': `token ${auth}`, 'Content-Type': 'application/json'}, headers: {'Authorization': `token ${auth}`, 'Content-Type': 'application/json'},

View File

@@ -19,12 +19,23 @@ dotenv.config({path: '.env.local', override: true, quiet: true, debug: false});
owner = process.env['GIT_OWNER'], owner = process.env['GIT_OWNER'],
repo = process.env['GIT_REPO'], repo = process.env['GIT_REPO'],
auth = process.env['GIT_TOKEN'], auth = process.env['GIT_TOKEN'],
labelEnabled = process.env['LABEL_ENABLED'] || 'Review/AI',
pr = process.env['PULL_REQUEST'], pr = process.env['PULL_REQUEST'],
host = process.env['AI_HOST'], host = process.env['AI_HOST'],
model = process.env['AI_MODEL'], model = process.env['AI_MODEL'],
token = process.env['AI_TOKEN']; token = process.env['AI_TOKEN'];
console.log(`Reviewing: ${root}\n`); console.log(`Reviewing: ${root}\n`);
const info = await fetch(`${git}/api/v1/repos/${owner}/${repo}/pulls/${pr}`)
.then(async resp => {
if(resp.ok) return resp.json();
throw new Error(`${resp.status} ${await resp.text()}`);
});
if(!info.labels.some(l => l.name === labelEnabled)) {
console.log('Skipping');
return process.exit();
}
const branch = process.env['GIT_BRANCH'] || await $`cd ${root} && git symbolic-ref refs/remotes/origin/HEAD`; const branch = process.env['GIT_BRANCH'] || await $`cd ${root} && git symbolic-ref refs/remotes/origin/HEAD`;
const comments = []; const comments = [];
const commit = await $`cd ${root} && git log -1 --pretty=format:%H`; const commit = await $`cd ${root} && git log -1 --pretty=format:%H`;
@@ -53,7 +64,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 some concluding remarks about the overall state of the changes.${existingComments}`, 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 a quick 75 words or less sitrep.${existingComments}`,
tools: [{ tools: [{
name: 'read_file', name: 'read_file',
description: 'Read contents of a file', description: 'Read contents of a file',
@@ -87,7 +98,16 @@ dotenv.config({path: '.env.local', override: true, quiet: true, debug: false});
}] }]
}); });
const messages = await ai.language.ask(gitDiff); const messages = await ai.language.ask(`Title: ${info.title || 'None'}
Description:
\`\`\`md
${info.body || 'None'}
\`\`\`
Git Diff:
\`\`\`
${gitDiff}
\`\`\``);
const summary = messages.pop().content; const summary = messages.pop().content;
if(git) { if(git) {
const res = await fetch(`${git}/api/v1/repos/${owner}/${repo}/pulls/${pr}/reviews`, { const res = await fetch(`${git}/api/v1/repos/${owner}/${repo}/pulls/${pr}/reviews`, {