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 🙏

© 2025 – Pkg Stats / Ryan Hefner

difflytic

v1.0.12

Published

AI-powered code review for GitLab/GitHub MRs using OpenAI and more.

Readme

AI-Driven Code Review Library 🚀

An AI-powered TypeScript npm library for automated code reviews during merge requests, designed for both free and premium use cases. It integrates with multiple SCM providers (e.g., GitHub, GitLab, Bitbucket) and supports dynamic AI models like OpenAI, Anthropic, and local models.

🎯 Project Goals

Create a TypeScript npm library that helps developers review code during merge requests using AI, with support for multiple providers and flexible AI model integrations. The library is designed for both Free and Premium versions, offering additional features for paying customers.

✨ Key Features

Free Version:

  • AI-powered code review using OpenAI (e.g., GPT-4).
  • Line-level code feedback.
  • GitHub and GitLab integration.
  • Basic automated labeling (e.g., "Review Passed", "Needs Adjustment").
  • Simple token management via environment variables.

Premium Version:

  • Dynamic AI model support (OpenAI, Anthropic, Local Models like LLaMA, Custom APIs).
  • Block-level and function-level feedback.
  • Support for additional providers (Bitbucket, Azure DevOps, Jira).
  • Customizable labeling and review thresholds.
  • Enhanced security with OAuth, token rotation, and encrypted storage.
  • Detailed analytics and usage insights (opt-in).

🔑 License Key Management

  • Uses JWT for premium feature access.
  • Central server or serverless function for key generation and verification.
  • Future-proof design for time-limited trials and feature-specific access.

🚀 Deployment Strategy

  • Standalone npm library (primary)
  • Dockerized CLI (optional)

📊 User Analytics and Feedback (Opt-In)

  • Track feature usage, performance, and error rates.
  • Provide insights for continuous improvement.
  • Respect user privacy with clear opt-in mechanisms.

Installation

Install via npm (recommended)

npm install -g difflytic

Or as a dev dependency in your project:

npm install --save-dev difflytic

Usage

As a CLI (recommended)

Global install

difflytic review gitlab <projectId> <mergeRequestIid> --mode=function

Local install (from project root)

npx difflytic review gitlab <projectId> <mergeRequestIid> --mode=function
  • --mode can be file, block, or function (default: file)
  • Example:
    npx difflytic review gitlab 12345 42 --mode=block

As a Library (programmatic usage)

import { GitLabProvider } from 'difflytic/dist/providers/GitLabProvider';
import { OpenAI } from 'difflytic/dist/ai/OpenAI';

const provider = new GitLabProvider();
const ai = new OpenAI();
const mrData = await provider.fetchMergeRequestData('yourProjectId', 'yourMergeRequestIid');
const changes = mrData.changes || [];
for (const file of changes) {
  const diff = file.diff || '';
  // ...process diff or use ai.analyzeCode(diff, 'function')
}

Environment Variables / Config

Set these as environment variables or in a .difflyticrc.json or config.json in your project root:

  • GITLAB_TOKEN (required)
  • OPENAI_API_KEY (required)
  • GITLAB_API_URL (optional, for self-hosted GitLab)

Example .difflyticrc.json:

{
  "GITLAB_TOKEN": "your_token",
  "OPENAI_API_KEY": "your_openai_key",
  "GITLAB_API_URL": "your_custom_gitlab_domain"
}

CI/CD Integration

To run difflytic automatically on every merge request, add a job to your .gitlab-ci.yml.

1. Set up GitLab CI/CD Variables

Go to Settings > CI/CD > Variables in your GitLab project and add:

  • GITLAB_TOKEN (with api scope, or at least read_api and read_repository)
  • OPENAI_API_KEY (your OpenAI API key)
  • GITLAB_API_URL (e.g., https://gitlab.com or your self-hosted domain, without /api/v4)

These variables will be available to your CI jobs as environment variables.

2. Add the difflytic Job to .gitlab-ci.yml

stages:
  - ai_review

ai_code_review:
  stage: ai_review
  image: node:18
  script:
    - npm install difflytic
    - npx difflytic review gitlab "$CI_PROJECT_ID" "$CI_MERGE_REQUEST_IID" --mode=function
  only:
    - merge_requests
  variables:
    GITLAB_TOKEN: "$GITLAB_TOKEN"
    OPENAI_API_KEY: "$OPENAI_API_KEY"
    GITLAB_API_URL: "$GITLAB_API_URL"
  • This job will run on every merge request.
  • It installs difflytic and runs the review command for the current MR.
  • The required tokens and API URL are securely provided via GitLab CI/CD variables.

3. What Happens

  • The job will:
    • Run the AI review on the merge request changes
    • Post comments and labels to the MR as configured

4. (Optional) Make the Job Required

  • In Settings > General > Merge request approvals or CI/CD > Pipelines, you can require this job to pass before merging.

License

MIT