npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ai-reviewer-core

v1.1.0

Published

Core AI code review logic - platform agnostic

Readme

ai-reviewer-core

Platform-agnostic AI code review library

npm version CI Coverage Status

This is the core library that powers AI code review across different platforms (GitHub Actions, Jenkins, etc.). It provides platform-agnostic logic for parsing diffs, communicating with LLMs, and generating code review comments.

Installation

npm install ai-reviewer-core

Quick Start

const { CodeReviewer, parseDiff } = require('ai-reviewer-core');

// Set up environment
process.env.LLM_API_KEY = 'your-openai-api-key';
process.env.LLM_ENDPOINT = 'https://api.openai.com/v1/chat/completions';

// Create reviewer instance
const reviewer = new CodeReviewer();

// Parse git diff
const diffData = `diff --git a/example.js b/example.js
index 123..456 100644
--- a/example.js
+++ b/example.js
@@ -1,3 +1,4 @@
 function hello() {
+  console.log("Hello World");
   return "world";
 }`;

// Review the changes
async function reviewCode() {
  const results = await reviewer.reviewChanges(diffData, {
    generateSummary: true
  });
  
  console.log('Summary:', results.summary);
  console.log('Comments:', results.comments);
  console.log('Metadata:', results.metadata);
}

reviewCode();

API Reference

CodeReviewer

Main class for reviewing code changes.

const { CodeReviewer } = require('@ai-reviewer/core');
const reviewer = new CodeReviewer();

Methods

reviewChanges(diffData, options)

Reviews code changes and generates comments.

Parameters:

  • diffData (string): Git diff content
  • options (object): Review options
    • generateSummary (boolean): Whether to generate a summary (default: true)
    • context (object): Additional context for the review

Returns: Promise

  • summary (string): Generated summary of changes
  • comments (Array): Array of review comments
  • hunks (Array): Parsed diff hunks
  • metadata (Object): Review metadata (timestamp, counts, etc.)
reviewHunk(hunk, options)

Reviews a single diff hunk.

generateSummary(diffData, options)

Generates a summary of the changes.

filterComments(comments, filters)

Filters comments based on criteria.

parseDiff(diffData)

Parses git diff data into structured hunks.

const { parseDiff } = require('@ai-reviewer/core');

const hunks = parseDiff(diffData);
console.log(hunks);

Returns: Array of hunk objects with:

  • filename (string): File name
  • changes (Array): Array of changes
  • hunkHeader (Object): Hunk metadata

LLM Integration

const { getReviewFromLLM, getSummaryFromLLM } = require('@ai-reviewer/core');

// Review a hunk
const reviewResponse = await getReviewFromLLM(hunk);

// Generate summary  
const summary = await getSummaryFromLLM(diffData);

Advanced Usage

Custom LLM Provider

const { LLMCoordinator, OpenAIProvider } = require('@ai-reviewer/core');

// Use existing provider
const coordinator = new LLMCoordinator();
const provider = coordinator.getProvider(); // OpenAI by default

// Or extend for custom provider
class CustomProvider extends OpenAIProvider {
  formatRequest(messages, options) {
    // Custom formatting
    return super.formatRequest(messages, options);
  }
}

Direct Platform Integration

const results = await reviewer.reviewChanges(diffData);

// Use structured data directly with Git platforms
results.comments.forEach(comment => {
  github.createLineComment({
    path: comment.filename,
    line: comment.line,
    body: comment.body  // Ready-to-post markdown
  });
});

// Optional summary as PR comment
if (results.summary) {
  github.createReview({ body: results.summary });
}

Environment Variables

  • LLM_API_KEY - Your LLM API key (required)
  • LLM_ENDPOINT - LLM API endpoint (required)
  • LLM_MODEL - Model to use (optional, defaults to gpt-3.5-turbo)

Platform Integrations

This core library is used by:

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Run npm test
  6. Submit a pull request

Testing

# Run tests
npm test

# Run with coverage
npm run test:coverage

# Watch mode
npm run test:watch

Building

# Build for distribution
npm run build

# Build CommonJS
npm run build:cjs

# Build ES modules
npm run build:esm

License

Apache-2.0

Changelog

See CHANGELOG.md for release history.