{"_id":"@agentic-reviewer/core","name":"@agentic-reviewer/core","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@agentic-reviewer/core","version":"1.0.0","description":"An autonomous, self-hosted, ReAct-style AI code review engine.","type":"module","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","postinstall":"node scripts/install.js"},"dependencies":{"adm-zip":"^0.5.17","dotenv":"^17.4.2"},"devDependencies":{"@types/node":"^24.13.1","typescript":"~5.3.3"},"_id":"@agentic-reviewer/core@1.0.0","_nodeVersion":"20.19.5","_npmVersion":"11.6.0","dist":{"integrity":"sha512-ntVxRbv3xj9pQFg/WvWmDC10pk0fe+2C7s4G5HJ2O8ZuNPuo4K0pg06ov0bDHfoHvaCQaiMlTiQ8h6Ioai+hBw==","shasum":"579b0ef0afc9d9dd85d44c5cb1cc8c76a19fd6fc","tarball":"https://registry.npmjs.org/@agentic-reviewer/core/-/core-1.0.0.tgz","fileCount":26,"unpackedSize":264236,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBLvpXi9LF/FUg904URmFbukj29L68MeyenEKzTCXkKUAiAcUlcLJP1UhYJJDdWm9vdSiUW+9a/4bXWvK9RVsjeWug=="}]},"_npmUser":{"name":"harshbajaj","email":"work.harshbajaj@gmail.com"},"directories":{},"maintainers":[{"name":"harshbajaj","email":"work.harshbajaj@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/core_1.0.0_1781155862718_0.8675545607099115"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-11T05:31:02.560Z","1.0.0":"2026-06-11T05:31:02.855Z","modified":"2026-06-11T05:31:03.115Z"},"maintainers":[{"name":"harshbajaj","email":"work.harshbajaj@gmail.com"}],"description":"An autonomous, self-hosted, ReAct-style AI code review engine.","readme":"# 🤖 Agentic Reviewer SDK\n\n**An autonomous, self-hosted, ReAct-style AI code review engine.**\n\n[![npm version](https://img.shields.io/npm/v/@agentic-reviewer/core.svg)](#)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](#)\n\nAgentic Reviewer is an enterprise-grade Node.js SDK that brings autonomous, agentic code reviews to your GitHub Pull Requests. Instead of relying on a simple \"pass diff to LLM\" script, this SDK utilizes a robust **ReAct (Reason + Act) tool-calling loop**. The AI autonomously fetches code context, analyzes specific chunks, posts inline comments on specific lines, and delivers a final verdict—all without human intervention.\n\nCrucially, **it runs 100% locally**. The SDK ships with an embedded [Ollama](https://ollama.com/) binary and automatically downloads the model weights, guaranteeing zero data leakage and zero setup friction for your development team.\n\n---\n\n## 🏗️ System Architecture\n\nBy moving to a stateless SDK, you have the absolute freedom to embed this Agent into any architecture. Below is the standard architecture for deploying this SDK as an automated webhook server.\n\n```mermaid\ngraph TD\n    A[GitHub PR Webhook] -->|Trigger| B(Webhook Server<br/>Node.js / Express)\n    B -->|Enqueue Job| C[Job Queue<br/>BullMQ + Redis]\n    C -->|Dequeue| D{Agent Worker<br/>ReviewAgent SDK}\n    \n    D -.->|Tool: fetch diff| E[GitHub API]\n    D -.->|Spawn Engine| F[Embedded Ollama<br/>qwen2.5-coder]\n    D -.->|Tool: post comments| E\n    \n    F -.->|Reason & Act| D\n    \n    C -->|Save Result| G[(PostgreSQL<br/>History)]\n```\n\n---\n\n## 🔄 The Agentic Loop\n\nThis is what separates the project from a simple 'call LLM with diff' script. The model runs in a ReAct-style loop — it reasons, picks a tool, observes the result, reasons again — until it decides the review is complete.\n\n1. **Receive PR Event:** You pass a GitHub PR URL to the SDK.\n2. **Fetch Diff:** The SDK calls the `fetch_diff` tool. GitHub API returns file-level diffs.\n3. **Feed to Ollama:** Diff + strict bug-hunter prompt + tool definitions are sent to the local `qwen2.5-coder` engine.\n4. **Tool-Calling Loop:** The model calls `analyze_code_chunk`, `post_inline_comment`, or `fetch_file_content` iteratively. The loop exits only when the model determines no further analysis is needed.\n5. **Post Comments:** The model calls `post_summary_comment` as its final action to approve, comment, or request changes.\n\n### 🛠️ Tool Definitions\n\nFour core tools give the agent everything it needs to conduct a thorough review:\n\n| Tool | Parameters | What it does |\n|------|------------|--------------|\n| `fetch_file_content` | `filename` | Fetches the full file for deeper context beyond the diff. |\n| `analyze_code_chunk` | `filename, chunk, focus` | Analyzes a diff chunk for bugs, security issues, or style problems. |\n| `post_inline_comment` | `filename, line, comment, severity` | Posts a review comment on a specific line (info/warning/error). |\n| `post_summary_comment`| `summary, verdict` | Posts the final PR summary with `approve`, `request_changes`, or `comment`. |\n\n---\n\n## 🧠 Model Selection\n\nAll models run locally via Ollama. By default, the SDK installs the 1.5b model. You can override this by setting the `AGENTIC_MODEL` environment variable before running `npm install`.\n\n| Install Command Prefix | Model | Size | Why it fits |\n|----------------------|-------|------|-------------|\n| *(None - Default)* | `qwen2.5-coder:1.5b` | ~1 GB | **Fast & Lightweight.** Great for general reviews, CI/CD runners, and standard laptops. |\n| `AGENTIC_MODEL=qwen2.5-coder:7b` | `qwen2.5-coder:7b` | ~4.7 GB | **Recommended.** Best-in-class at 7B for code, native tool-calling support. Requires more RAM/VRAM. |\n| `AGENTIC_MODEL=deepseek-coder-v2` | `deepseek-coder-v2`| ~9 GB | Stronger reasoning for complex diffs. (You can pass **any** model name here, as long as Ollama supports it and it has native tool-calling capabilities). |\n\n---\n\n## 🚀 Installation & Setup\n\nBecause the SDK utilizes an embedded version of Ollama, there are **no external system dependencies** required (No Docker, no Python, no C++ build tools). \n\n### 1. Install the SDK\nBy default, installing the SDK will automatically download the 1.5b model. \n\n```bash\nnpm install @agentic-reviewer/core\n```\n\nIf you want the more powerful 7b model (recommended if you have 16GB+ RAM), prepend the install command with the model environment variable:\n\n```bash\n# Mac/Linux:\nAGENTIC_MODEL=qwen2.5-coder:7b npm install @agentic-reviewer/core\n\n# Windows (PowerShell):\n$env:AGENTIC_MODEL=\"qwen2.5-coder:7b\"; npm install @agentic-reviewer/core\n```\n*(Note: Because the SDK downloads real AI model weights, the first-time installation will take ~5 minutes depending on your internet connection. NPM hides script output by default and will just show a spinning circle. If you want to see the live download progress bar, append `--foreground-scripts` to your install command!)*\n\n### 2. Environment Configuration\nSecurely store your GitHub Personal Access Token (requires `repo` scope).\n```env\nGITHUB_TOKEN=ghp_your_secure_token_here\n```\n\n### 3. Usage\n```javascript\nimport 'dotenv/config';\nimport { ReviewAgent } from '@agentic-reviewer/core';\n\nasync function runReview() {\n  // The SDK automatically spawns the background Ollama engine, \n  // runs the agentic loop, and cleanly shuts down.\n  const result = await ReviewAgent.analyzePR('https://github.com/owner/repo/pull/123', {\n    githubToken: process.env.GITHUB_TOKEN,\n    model: 'qwen2.5-coder:1.5b' // Must match the package you installed\n  });\n\n  console.log('Verdict:', result.verdict);\n  console.log('Summary:', result.summary);\n}\n\nrunReview();\n```\n\n---\n\n## 💡 Use Cases\n\n### 1. The Automated Webhook Server (Express + BullMQ)\nBuild a lightweight Express server combined with BullMQ. When GitHub fires a webhook, push the URL to the queue, and let your Worker execute the SDK.\n\n### 2. CI/CD Pipeline Integration (GitHub Actions)\nRun the SDK directly inside a GitHub Actions runner. Because the SDK is self-contained and downloads its own Ollama binary, it can block PR merges natively inside your CI/CD pipeline.\n\n### 3. Custom Internal Developer Tools (CLI)\nWrap the SDK in a local CLI tool (`npm run review --pr=123`). The SDK outputs the review results directly to the terminal, allowing developers to fix bugs locally before anyone else sees them.\n\n---\n\n## 📝 License\nMIT License.\n","readmeFilename":"README.md","_rev":"1-759f0f3c6423c20530d163a761e71e55"}