Skip to main content
Glama
README.md
<p align="center">
  <img src="./docs/logo.svg" width="96" height="96" alt="CodePulse Logo" />
</p>

<h1 align="center">CodePulse</h1>

<p align="center">
  <strong>Native Windows Desktop & Self-Hostable AI Code Intelligence, Hybrid AST+SAST Review, Full-Repo Audit, Auto-Docs & Closed-Loop MCP Verification</strong>
</p>

<p align="center">
  <a href="https://github.com/ymorningstar/CodePulse/actions/workflows/ci.yml"><img src="https://github.com/ymorningstar/CodePulse/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
  <a href="https://github.com/ymorningstar/CodePulse/releases/latest"><img src="https://img.shields.io/github/v/release/ymorningstar/CodePulse?label=Releases&color=blue" alt="GitHub Release" /></a>
  <a href="./LICENSE"><img src="https://img.shields.io/badge/License-AGPL--3.0%20%2B%20Commercial-indigo.svg" alt="AGPL-3.0 + Commercial" /></a>
  <a href="./templates/LICENSE"><img src="https://img.shields.io/badge/Templates%20%26%20SDK-MIT-green.svg" alt="MIT Templates & SDK" /></a>
  <img src="https://img.shields.io/badge/Windows-.exe%20Native%20App%20%7C%20Auto--Update-0078D6.svg" alt="Windows .exe" />
  <a href="https://github.com/apps/codepulsebot"><img src="https://img.shields.io/badge/GitHub%20App-codepulsebot-24292F.svg" alt="GitHub App" /></a>
  <a href="./server.json"><img src="https://img.shields.io/badge/MCP-Closed--Loop%20Server-10B981.svg" alt="MCP Server" /></a>
  <a href="./benchmarks/run-eval.ts"><img src="https://img.shields.io/badge/AACR%20Sample-F1%20100%25%20%7C%2095%25%20Token%20Saved-brightgreen.svg" alt="AACR Benchmark" /></a>
</p>

<p align="center">
  <strong>English</strong> | <a href="./README.es.md">Español</a> | <a href="./README.ar.md">العربية</a> | <a href="./README.fr.md">Français</a> · <a href="./docs/wiki/Home.md">Wiki</a>
</p>

> **One BYOK AI API key. Zero VPS or cloud subscription required.** Download the native desktop app for **Windows** (`CodePulse-Setup-1.2.0-x64.exe`), **macOS** (`CodePulse-1.2.0-arm64.dmg` / `x64.dmg`), or **Linux** (`.deb`, `.rpm`, `.AppImage`, `.tar.gz`), finish the 4-step Onboarding Wizard (AI Key + 1-Click GitHub Device Flow + Repo Picker + Terms/Privacy), and run AST Blast-Radius + Cross-Layer Radar + OSV CVE + SEO & GEO + Two-Persona Debate reviews, whole-`main` audits, auto-docs, or closed-loop MCP verification locally or via Docker (`/mcp`).

---

## What's New in `v1.2.0`

- **Full Multi-Platform Releases (Windows + Unsigned $0 macOS + Multi-Distro Linux):** Builds NSIS & Portable Windows `.exe` (`latest.yml` auto-update), Apple Silicon (`arm64`) & Intel (`x64`) macOS `.dmg`/`.zip` (`$0` unsigned + graceful GitHub Release update prompt), and Linux `.deb` (Ubuntu/Debian/Mint), `.rpm` (Fedora/RHEL/openSUSE), `.AppImage`, and `.tar.gz` + `SHA256SUMS.txt`.
- **Hybrid Cloudflare Worker + D1 + PostHog Privacy Telemetry ([`infra/telemetry-worker/`](./infra/telemetry-worker/)):** Auditable serverless receiver with strict 8KB JSON allowlist, D1 SQL aggregates, hidden `POSTHOG_API_KEY` fan-out (`$ip: null`), and token-protected `GET /stats`. Strictly **opt-in ONLY** (`false` by default).
- **4-Language Documentation & Auto-Synced GitHub Wiki:** Synced `README.md` (`EN`), `README.es.md` (`ES`), `README.ar.md` (`AR RTL`), `README.fr.md` (`FR`) + sidebar-navigated [`docs/wiki/`](./docs/wiki/Home.md) & automated `.github/workflows/sync-wiki.yml`.
- **Previous Highlights (`v1.1.0`):** Non-blocking Electron `utilityProcess` worker, SEO & GEO AI Search Visibility audit mode (`seo-geo`), 2-level Hierarchical Collapsible Findings Explorer, global Toast Stack, Tabbed Settings Center (`Ctrl+,` with Obsidian/Slate/Light themes), and [`PRIVACY.md`](./PRIVACY.md) + [`TERMS.md`](./TERMS.md).

---

## Complete Scan Modes & What Bugs CodePulse Catches

| Mode | Scope & Engines | AI Tokens |
| --- | --- | --- |
| **`fast`** | AST Blast Radius + Built-in Multi-Language SAST + OSV CVE + Team Memory | **0 tokens** |
| **`security`** | Deep OWASP/Auth/Secrets/XSS/SQLi + External SAST + Cross-Layer Radar + OSV CVEs | Low–Med |
| **`debate`** *(Default)* | Cohesive AST Bundles + Single-Key Two-Persona Debate (`Finder` vs `Skeptic` + Judge) + Position Validator | Medium |
| **`adversarial`** | Red-team exploit simulation, TOCTOU race conditions, financial rounding & RBAC bypasses | Med–High |
| **`deep`** | Exhaustive multi-pass bundle analysis + Cross-Layer Contract Radar + OSV + Reflection Filter | High |
| **`main_full`** | Whole-repository SHA-cached Semantic Slices + Cross-Layer Radar + OSV + SEO/GEO + Project Pulse (`0–100`) | Scalable |
| **`seo-geo`** | Technical SEO (`CP-SEO-*`) + GEO AI Search Visibility (`CP-GEO-*`) with `seoScore` & `geoScore` | 0–Low |
| **`docs`** | Living `ARCHITECTURE.md`, `API_CATALOG.md`, `DATABASE_ERD.md`, `RBAC_MATRIX.md` + local Mermaid | Low |

**Detected Vulnerability & Engineering Defect Categories:**
1. **Secrets & Cloud Credentials (`CP-SEC-*`):** Hardcoded API keys, Gemini/OpenAI/Anthropic/GitHub/AWS tokens, DB passwords in URIs.
2. **Injection & Unsafe Sinks (`CP-SQL-*`, `CP-XSS-*`):** Interpolated template SQL queries, Supabase/PostgREST `.or()` filter injection, `dangerouslySetInnerHTML`, `.innerHTML`, `eval`, `new Function`.
3. **Authentication & Authorization (`CP-AUTH-*`):** Hardcoded `return true` auth guards, `rejectUnauthorized: false`, unverified `jwt.decode()`, unguarded `/admin` & `/billing` routes, cookie mutations without CSRF/Origin checks.
4. **Financial Precision & Concurrency (`CP-FIN-*`, `CP-CONC-*`):** `parseFloat()` / float multiplication on monetary amounts, shared mutable counters/balances.
5. **Cross-Layer Contract Drift:** SQL/Prisma schema column mismatches vs TypeScript interfaces, currency unit drift (`cents` vs `dollars`), frontend `fetch('/api/...')` calls targeting non-existent/wrong-method backend routes.
6. **Zero-Token Dependency CVEs (`osv.dev`):** Known advisories across `package.json`, `requirements.txt`, `Cargo.toml`, and `go.mod`.
7. **Technical SEO & GEO AI Search (`CP-SEO-*`, `CP-GEO-*`):** Missing/generic titles, descriptions, canonicals, `robots.txt` blocks (`Disallow: /` or `GPTBot`/`PerplexityBot` blocks), missing `llms.txt`, invalid Schema.org JSON-LD, CSR `"use client"` empty HTML shells.

---

## Demo (15-Second Closed-Loop Verification)

> *Hero demo GIF slot — follow [`docs/demo-recording-script.md`](./docs/demo-recording-script.md) to record `docs/demo.gif` showing an AI coding agent triggering `start_scan -> wait_for_scan -> fix -> revalidate_findings -> PASS`.*

---

## Architecture

```mermaid
flowchart LR
  Agent["AI Coding Agent (Antigravity / Cursor / Claude Code / Codex / Windsurf / OpenCode)"] <-->|"MCP (start_scan -> wait_for_scan -> get_scan_result -> revalidate_findings)"| MCP["CodePulse MCP & Parallel Queue"]
  MCP --> Core["Hybrid Engine: Tree-sitter WASM AST + RDFormat/SARIF SAST + 2-Persona Debate"]
  Core --> Validator["Position-Drift Validator + Reflection Filter"]
  Validator -->|"Device Flow / codepulsebot App / Zero-Port Poller"| GH["GitHub PR Inline Suggestions & Babysitter"]
  Validator -->|"Safe Path Guard"| Out["Native Windows Desktop App & Local .md Reports"]
```

---

## CodePulse vs CodeRabbit SaaS & Raw Diff Bots

| Capability | CodePulse (`v1.2.0`) | CodeRabbit / Cloud SaaS Bots | Raw Diff Prompt Bots |
| --- | --- | --- | --- |
| **Native Windows Desktop `.exe` + System Tray + Auto-Updater** | **Yes** (`Setup.exe` & `Portable.exe`) | Cloud-only | DIY scripts |
| **Zero-Config In-App Setup (AI Key + Device Flow + PR Picker)** | **Yes** (3-step wizard, zero `.env` editing) | Cloud OAuth | Manual env/CLI |
| **Single BYOK AI Key** (Gemini / OpenAI / Anthropic / OpenRouter / Ollama) | **Yes** (1 key runs all passes) | Paid per-seat SaaS | Single-pass only |
| **Local `web-tree-sitter` AST Blast-Radius Graph** | **Yes** (SQLite-cached callers & tests) | Cloud-hosted index | None |
| **Single-Key Two-Persona Debate + Adversarial Mode** | **Yes** (`Agreed` vs `Contested`) | No | No |
| **Whole-`main` Semantic Slice Audit + SQL/TS Drift** | **Yes** (`scan`) | Limited | No |
| **Auto-Documentation (`ARCHITECTURE.md`, API, ERD, RBAC)** | **Yes** (`docs`) | No | No |
| **Isolated `git worktree` Auto-Fix (`uncertain -> verified_fixed`)** | **Yes** (opt-in + `revalidate`) | Unverified suggestions | No |
| **Closed-Loop MCP Server + Stop-Review Gate** | **Yes** (10 tools + `stop-gate`) | No | No |

---

## Installation (Choose Any Method)

### 1. Native Desktop App — Windows, macOS & Multi-Distro Linux (Zero Node.js Required)
Download directly from [**GitHub Releases (`v1.2.0`)**](https://github.com/ymorningstar/CodePulse/releases/latest):

- **Windows 10/11 (`x64`):** `CodePulse-Setup-1.2.0-x64.exe` (Installer + Auto-Updater & System Tray) · `CodePulse-Portable-1.2.0-x64.exe`
  ```powershell
  scoop install https://raw.githubusercontent.com/ymorningstar/CodePulse/main/packaging/scoop/codepulse.json
  winget install CodePulse.CodePulse
  ```
- **macOS (`arm64` Apple Silicon & `x64` Intel — Free Unsigned Open-Source Build):**
  Download `CodePulse-1.2.0-arm64.dmg` (or `x64.dmg` / `.zip`). Because CodePulse is free open-source without a \$99/yr Apple notarization cert, on first launch **Right-Click `CodePulse.app` → Open**, or run:
  ```bash
  xattr -cr /Applications/CodePulse.app
  ```
- **Linux (`x64` All Major Distros):**
  - **Ubuntu / Debian / Mint / Pop!_OS:** `sudo apt install ./CodePulse-1.2.0-x64.deb`
  - **Fedora / RHEL / openSUSE:** `sudo dnf install ./CodePulse-1.2.0-x64.rpm`
  - **Universal / Portable:** `chmod +x CodePulse-1.2.0-x64.AppImage && ./CodePulse-1.2.0-x64.AppImage` or `CodePulse-1.2.0-x64.tar.gz`

### 2. Global CLI / Zero-Install (`npx`)
Requires Node.js `>=22.0.0`:
```bash
# Connect all detected IDEs & AI coding agents in 1 command
npx codepulse install

# Launch the 3-Zone Bilingual Cockpit (http://127.0.0.1:4310)
npx codepulse ui

# Or install globally
npm install -g codepulse
```

### 3. Self-Hosted Docker Server
```bash
git clone https://github.com/ymorningstar/CodePulse.git
cd CodePulse
cp .env.example .env
docker compose up -d
```
Prebuilt image: `ghcr.io/ymorningstar/codepulse:latest` (persists SQLite in `/data` and `.md` exports in `/reports`).

### 4. GitHub Action (6-Line CI Review Gate)
Add `.github/workflows/codepulse.yml` to any repository:
```yaml
name: CodePulse PR Review
on:
  pull_request:
    types: [opened, synchronize, reopened]
permissions:
  contents: read
  pull-requests: write
  checks: write
jobs:
  codepulse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: ymorningstar/CodePulse@main
        with:
          mode: debate
          ai_provider: gemini
          ai_api_key: ${{ secrets.GEMINI_API_KEY }}
          github_token: ${{ secrets.GITHUB_TOKEN }}
```

### 5. GitHub App Bot (`codepulsebot`)
- **Official Hosted App:** Install [**https://github.com/apps/codepulsebot**](https://github.com/apps/codepulsebot) on your repositories (used with 1-Click Device Flow inside the Desktop App!).
- **Self-Hosted `[bot]` Manifest:** Run `npx codepulse github-app setup` — see [`docs/GITHUB_APP_SETUP.md`](./docs/GITHUB_APP_SETUP.md).

---

## Complete CLI Reference

| Command | Description | Key Flags |
| --- | --- | --- |
| `codepulse ui` | Launch 3-Zone Web Cockpit + WebSocket queue | `--port 4310`, `--host 127.0.0.1` |
| `codepulse install` | Auto-detect & wire MCP, skills, and hooks | `--dry-run`, `--platform <name>`, `--no-hooks` |
| `codepulse doctor` | Check Node, git, SAST tools, AI key & bridges | `--repo <path>` |
| `codepulse uninstall` | Cleanly remove CodePulse MCP entries | `--platform <name>` |
| `codepulse github-app setup` | Launch 1-Click GitHub App Manifest flow | `--org <org>`, `--webhook-url <url>` |
| `codepulse review` | Run AST+SAST+Debate review | `--local`, `--from <ref>`, `--to <ref>`, `--mode fast\|deep\|debate\|adversarial\|security`, `--wait`, `--json`, `--save-md [dir]` |
| `codepulse scan` | Whole-`main` semantic slice deep audit | `--force`, `--json`, `--repo <path>` |
| `codepulse docs` | Generate `ARCHITECTURE.md`, API, DB ERD & RBAC | `--out ./docs`, `--repo <path>` |
| `codepulse fix` | Opt-in isolated `git worktree` auto-fix | `--finding <id>`, `--opt-in` |
| `codepulse revalidate` | Re-verify fixes & promote `verified_fixed` | `--scan <jobId>`, `--repo <path>` |
| `codepulse stop-gate` | Stop-Review Gate hook (`ALLOW:` vs `BLOCK:`) | `--repo <path>` |
| `codepulse mcp` | Start stdio MCP server for coding agents | `--stdio`, `--repo <path>` |

---

## PR Comment Slash Commands & Natural Chat

Comment directly on any connected GitHub Pull Request (in **English or Arabic**):
- `/codepulse review` or `/review` · `/deep-review` · `/debate` · `/adversarial` · `/security` · `/scan-main` · `/describe` · `/add_docs` · `/docs` · `/improve` · `/explain` · `/autofix <findingId>` · `/revalidate`
- **Free-form Q&A:** `@codepulse Why is this payment check flagged?` or `@codepulse هل دالة الدفع آمنة من التكرار؟`

---

## Closed-Loop AI Agent Integration (MCP)

CodePulse exposes 10 MCP tools (`start_scan`, `wait_for_scan`, `get_scan_result`, `revalidate_findings`, `scan_main_branch`, `generate_docs`, `get_blast_radius`, `run_sast`, `propose_autofix`, `export_markdown`).

- **Antigravity / Cursor / Claude Code / Windsurf:**
```json
{
  "mcpServers": {
    "codepulse": {
      "command": "npx",
      "args": ["-y", "codepulse", "mcp", "--stdio"]
    }
  }
}
```
*(Or run `npx codepulse install` — automatically uses `[node, <absolute cli/dist/index.js>, "mcp", "--stdio"]` on Windows if `codepulse` is not on `PATH`!)*

---

## `.codepulse.yml` & Custom Rule Packs

```yaml
# .codepulse.yml
attribution:
  enabled: true              # Set false to hide the PR attribution footer completely
  show_token_savings: true   # Show AST-graph token savings telemetry in PR summaries
  repo_url: https://github.com/ymorningstar/CodePulse
```

---

## Benchmark Proof (`benchmarks/run-eval.ts`)

```bash
node benchmarks/run-eval.ts
```

Measured on [`benchmarks/fixtures/aacr-sample.json`](./benchmarks/fixtures/aacr-sample.json):

| Metric | CodePulse (AST+SAST) | Raw-Diff Baseline |
| --- | ---: | ---: |
| Precision | **100.0%** | — |
| Recall | **100.0%** | — |
| F1 Score | **100.0%** | — |
| Wall-Clock Time | **2339 ms** | — |
| Context Tokens | **258** | 4892 (**95% saved**) |

---

## Licensing, Security & Governance

- **Core Engine, CLI, Desktop, Server & UI:** [`AGPL-3.0-only`](./LICENSE)
- **Templates, `action.yml`, & `packages/mcp-client-sdk`:** [`MIT`](./templates/LICENSE)
- **Commercial / White-Label License:** [`COMMERCIAL-LICENSE.md`](./COMMERCIAL-LICENSE.md)
- **Privacy, Terms & Telemetry:** [`PRIVACY.md`](./PRIVACY.md) · [`TERMS.md`](./TERMS.md) · [`docs/TELEMETRY_SETUP.md`](./docs/TELEMETRY_SETUP.md) · [`docs/wiki/`](./docs/wiki/Home.md)
- **Trademark, Security & Contributing:** [`TRADEMARK.md`](./TRADEMARK.md) · [`NOTICE`](./NOTICE) · [`SECURITY.md`](./SECURITY.md) · [`CONTRIBUTING.md`](./CONTRIBUTING.md) · [`CLA.md`](./CLA.md)