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

code-sage-cli

v1.3.1

Published

Pragmatic, Gemini-powered AST Call-Graph AI Code Reviewer CLI

Readme

Code-Sage CLI

An agentic AI code reviewer built on a LangGraph state machine and a local AST call-graph engine.
Runs in GitHub Actions to post inline reviews directly onto Pull Request diffs.


Architecture

Code-Sage is implemented as a LangGraph StateGraph — a directed agentic execution graph where each node is an isolated stage that reads from and writes to shared typed state. The graph routes conditionally at runtime based on what it discovers.

flowchart TD
    A([START]) --> B[load_context\nRead git diff · detect languages]
    B -->|no changed files| Z([END])
    B --> C[planner\nGemini builds per-file review strategy]
    C --> D[file_reviewer\nReview each file · comments merged via state reducer]
    D --> E[build_ast\nLocal TypeScript AST call graph\nNo LLM · finds downstream callers]
    E -->|no callers affected| Z
    E --> F[cross_file_analyzer\nGemini checks caller compatibility]
    F --> Z

    style A fill:#111,color:#fff,stroke:#333
    style Z fill:#111,color:#fff,stroke:#333
    style B fill:#1a1a1a,color:#eee,stroke:#444
    style C fill:#1a1a1a,color:#eee,stroke:#444
    style D fill:#1a1a1a,color:#eee,stroke:#444
    style E fill:#1a1a1a,color:#eee,stroke:#444
    style F fill:#1a1a1a,color:#eee,stroke:#444

What makes this architecture meaningful:

  • Conditional edges: The cross-file LLM call only fires if the AST graph finds unmodified callers affected by the change. Empty diffs exit at the first edge. No wasted API calls.
  • State reducer on comments: Each node appends review findings to shared state independently. file_reviewer and cross_file_analyzer never overwrite each other.
  • Node isolation: Each node can fail and retry independently. A failed file review does not abort the cross-file analysis stage.
  • AST runs local: The call graph is built entirely on-device. The LLM only ever sees the git diff and the 10-line snippets surrounding affected caller sites — no full codebase uploads.

Tech Stack

| Layer | Technology | | :--- | :--- | | Agentic Graph | LangGraph @langchain/langgraph | | LLM | Google Gemini via Vercel AI SDK @ai-sdk/google | | AST Parsing | TypeScript Compiler API | | GitHub Integration | Octokit REST @octokit/rest | | CLI | ora · chalk | | Schema Validation | Zod |


Usage

Option A — Run Locally

Review uncommitted changes before pushing. No GitHub required.

1. Get a free API key from Google AI Studio

2. Set the key:

# macOS / Linux
export GEMINI_API_KEY="your_key_here"

# Windows PowerShell
$env:GEMINI_API_KEY="your_key_here"

Or place GEMINI_API_KEY=your_key_here in a .env file at the project root.

3. Run:

# All uncommitted changes
npx code-sage-cli

# Staged only
npx code-sage-cli --staged

# Unstaged only
npx code-sage-cli --unstaged

Findings are printed directly to the terminal — severity level, file, line, problem, consequences, and suggested patch where applicable.


Option B — GitHub Actions (Automated PR Reviews)

Code-Sage posts inline review comments directly onto the Pull Request diff. No configuration file to write manually.

1. Add your API key to GitHub Secrets

Go to your repository → SettingsSecrets and variablesActionsNew repository secret

  • Name: GEMINI_API_KEY
  • Value: your Gemini API key

2. Auto-generate the workflow file

In the root of your repository, run:

npx code-sage-cli --init

This creates .github/workflows/code-review.yml with correct permissions and runner config.

3. Commit and push

git add .github/workflows/code-review.yml
git commit -m "ci: add code-sage automated PR review"
git push

Every Pull Request opened or updated from this point will automatically trigger Code-Sage. It will run the full agentic pipeline against the PR diff and post findings as inline comments on the changed lines.


CLI Reference

| Flag | Description | | :--- | :--- | | (none) | Review all uncommitted changes | | --staged | Review staged changes only | | --unstaged | Review unstaged changes only | | --init | Generate the GitHub Actions workflow file | | --force | Bypass the large-file and initial-commit guards |

| Environment Variable | Description | | :--- | :--- | | GEMINI_API_KEY | Required. Google Gemini API key. | | GITHUB_TOKEN | Required in CI. Provided automatically by GitHub Actions. | | GEMINI_PRIMARY_MODEL | Optional. Override the primary model. Default: gemini-2.5-flash | | GEMINI_BACKUP_MODEL | Optional. Override the fallback model. Default: gemini-2.5-flash-lite |


Contributing

git clone https://github.com/Rounak87/Code-Sage-cli.git
cd Code-Sage-cli
npm install
npm run build
npm link
code-sage-cli --staged

License

MIT