Use npx instead
Some checks failed
Code review / review (pull_request) Failing after 4s
Publish Library / Build NPM Project (push) Failing after 20s
Publish Library / Tag Version (push) Has been skipped

This commit is contained in:
2025-12-27 22:03:14 -05:00
parent e0f3a3cd82
commit a24961a55c
7 changed files with 84 additions and 115 deletions

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env node
import {Ai} from '@ztimson/ai-utils';
import {$} from '@ztimson/node-utils';
import * as os from 'node:os';
@@ -5,12 +7,14 @@ import * as path from 'node:path';
import * as fs from 'node:fs';
import * as dotenv from 'dotenv';
dotenv.config({debug: false});
dotenv.config({path: '.env.local', override: true, debug: false});
dotenv.config({quiet: true, debug: false});
dotenv.config({path: '.env.local', override: true, quiet: true, debug: false});
(async () => {
const root = process.argv[2] || process.cwd(),
branch = process.env['GIT_BRANCH'] || await $`cd ${root} && git symbolic-ref refs/remotes/origin/HEAD`,
let p = process.argv[process.argv.length - 1];
if(p === 'review' || p.endsWith('review.mjs')) p = null;
const root = p || process.cwd(),
git = process.env['GIT_HOST'],
owner = process.env['GIT_OWNER'],
repo = process.env['GIT_REPO'],
@@ -21,11 +25,11 @@ dotenv.config({path: '.env.local', override: true, debug: false});
token = process.env['AI_TOKEN'];
console.log(`Reviewing: ${root}\n`);
const branch = process.env['GIT_BRANCH'] || await $`cd ${root} && git symbolic-ref refs/remotes/origin/HEAD`;
const comments = [];
const commit = await $`cd ${root} && git log -1 --pretty=format:%H`;
const gitDiff = await $`cd ${root} && git diff ${branch}`;
let options = {ollama: {model, host}};
if(host === 'anthropic') options = {anthropic: {model, token}};
else if(host === 'openai') options = {openAi: {model, token}};
@@ -33,7 +37,7 @@ dotenv.config({path: '.env.local', override: true, debug: false});
...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 brief bullet point summary in markdown.`,
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.`,
tools: [{
name: 'read_file',
description: 'Read contents of a file',