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

@kb-labs/review-core

v2.94.0

Published

Core orchestration logic for AI Review plugin.

Readme

@kb-labs/review-core

Core orchestration logic for AI Review plugin.

Overview

This package contains the main orchestrator that coordinates:

  • Heuristic analysis engines (ESLint, Ruff, etc.)
  • LLM-based analyzers (naming, architecture, logic bugs)
  • Caching via State Broker
  • Deduplication with engine type priority
  • Analytics tracking

Usage

import { runReview } from '@kb-labs/review-core';

const result = await runReview({
  mode: 'heuristic', // 'heuristic' | 'full' | 'llm'
  scope: 'changed',  // 'all' | 'changed' | 'staged'
  cwd: '/path/to/project',
  files: ['src/**/*.ts'],
  presetId: 'typescript-strict',
  config: {
    eslintConfig: '.eslintrc.json',
  },
});

console.log(`Found ${result.findings.length} issues`);
console.log(`Analyzed ${result.metadata.analyzedFiles} files`);
console.log(`Duration: ${result.metadata.duration}ms`);

Review Modes

heuristic (CI Mode)

Fast, deterministic analysis using only heuristic engines:

  • ✅ ESLint, Ruff, golangci-lint, Clippy
  • ✅ No LLM calls (free, fast, predictable)
  • ✅ Perfect for CI pipelines
  • ❌ Limited to syntactic issues
await runReview({
  mode: 'heuristic',
  scope: 'changed',
  cwd: process.cwd(),
});

Use cases:

  • CI/CD pipelines
  • Pre-commit hooks
  • Quick local checks

full (Local Mode)

Comprehensive analysis with heuristic + LLM:

  • ✅ All heuristic engines
  • ✅ LLM analyzers for complex issues
  • ✅ Cached LLM results (fast on second run)
  • ❌ Costs tokens (configurable budget)
await runReview({
  mode: 'full',
  scope: 'all',
  cwd: process.cwd(),
  presetId: 'typescript-strict',
});

Use cases:

  • Local development
  • Pre-PR review
  • Weekly codebase audits

llm (Deep Analysis Mode)

LLM-only analysis for semantic issues:

  • ❌ No heuristic engines
  • ✅ LLM analyzers for naming, architecture, logic bugs
  • ✅ Best quality (uses large tier LLM)
  • ❌ Most expensive
await runReview({
  mode: 'llm',
  scope: 'staged',
  cwd: process.cwd(),
});

Use cases:

  • Architecture reviews
  • Complex refactoring
  • Semantic bug detection

Scope Options

Control which files to analyze:

  • all - Analyze entire codebase
  • changed - Analyze files changed vs main branch (git diff)
  • staged - Analyze only staged files (git diff --staged)
await runReview({
  mode: 'heuristic',
  scope: 'changed', // Only changed files
  cwd: process.cwd(),
});

Platform Integration

The orchestrator uses KB Labs platform composables:

import { useLLM, useCache, useAnalytics } from '@kb-labs/sdk';

// Inside orchestrator
const llm = useLLM({ tier: 'medium' });
const cache = useCache();
const analytics = useAnalytics();

// LLM tier selection
// - 'small': Simple tasks (categorization, quick fixes)
// - 'medium': Standard analysis (most LLM analyzers)
// - 'large': Complex reasoning (architecture, logic bugs)

Caching

Results are cached via State Broker for fast repeat analysis:

// First run: ~10s (runs ESLint)
await runReview({ mode: 'heuristic', scope: 'all', cwd: '.' });

// Second run: ~100ms (cached)
await runReview({ mode: 'heuristic', scope: 'all', cwd: '.' });

Cache keys include:

  • Engine ID (eslint, ruff, etc.)
  • Scope (all, changed, staged)
  • Preset ID
  • File patterns

Cache invalidation:

  • TTL: 1 hour
  • Manual: Clear State Broker cache
  • Automatic: File content hash changes (TODO)

Deduplication

Findings from multiple engines are deduplicated using:

  1. Fingerprint: sha1(ruleId|file|bucket|snippetHash)
  2. Engine Type Priority: compiler > linter > sast > ast > llm
  3. Severity: blocker > high > medium > low > info (if same type)

Example:

// Input: 3 findings for same issue
// - ESLint: "no-unused-vars" (linter, medium)
// - TSC: "TS6133" (compiler, high)
// - Semgrep: "unused-variable" (sast, low)

// Output: 1 finding (TSC wins: compiler > linter > sast)
{
  id: 'tsc:/path/file.ts:TS6133:10:5',
  engine: 'tsc',
  severity: 'high',
  message: "'foo' is declared but never used.",
}

Analytics

The orchestrator tracks analytics events:

  • review:started - Review started
  • review:completed - Review completed successfully
  • review:failed - Review failed with error

Metrics:

  • Mode used
  • Findings count
  • Duration
  • Engines used
  • Files analyzed

Configuration

Pass config via ReviewRequest:

await runReview({
  mode: 'full',
  scope: 'all',
  cwd: '/path/to/project',
  files: ['src/**/*.ts', 'src/**/*.tsx'],
  presetId: 'typescript-strict',
  config: {
    eslintConfig: '.eslintrc.json',
    // Add more engine configs here
  },
});

Architecture

ReviewOrchestrator
│
├─ runHeuristicAnalysis()
│   ├─ runESLint() → analyzeWithESLint()
│   ├─ runRuff() (TODO)
│   ├─ runGolangci() (TODO)
│   └─ deduplicateFindings()
│
├─ runFullAnalysis()
│   ├─ runHeuristicAnalysis()
│   ├─ runLLMAnalyzers() (TODO)
│   └─ deduplicateFindings()
│
└─ runLLMAnalysis()
    ├─ runLLMAnalyzers() (TODO)
    └─ deduplicateFindings()

Error Handling

The orchestrator catches and tracks errors:

try {
  const result = await runReview(request);
  console.log('Success:', result.findings.length);
} catch (error) {
  // Analytics tracked automatically
  console.error('Review failed:', error);
}

Future Enhancements

Phase 1 (Current)

  • ✅ Heuristic mode with ESLint
  • ✅ Deduplication with engine type priority
  • ✅ Platform integration (useLLM, useCache, useAnalytics)
  • ⏳ CLI commands

Phase 2

  • [ ] Full mode with LLM analyzers
  • [ ] More heuristic engines (Ruff, golangci, Clippy)
  • [ ] Content-hash based caching
  • [ ] Preset system

Phase 3

  • [ ] LLM mode for semantic analysis
  • [ ] Agent-powered preset generation
  • [ ] Interactive review UI
  • [ ] Auto-fix support