{"_id":"@abhidobariya/codeguard","_rev":"2-1ae0bc35415351bf9aefd102a8c93214","name":"@abhidobariya/codeguard","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"@abhidobariya/codeguard","version":"1.0.0","keywords":["ai","code-review","bug-detection","typescript","csharp","developer-tools"],"author":{"name":"abhidobariya"},"license":"ISC","_id":"@abhidobariya/codeguard@1.0.0","maintainers":[{"name":"abhidobariya","email":"abhidobariya2004@gmail.com"}],"bin":{"codeguard":"dist/cli/index.js"},"dist":{"shasum":"1f31ee07f3f5311b14a19ffa36aa768478adc4fc","tarball":"https://registry.npmjs.org/@abhidobariya/codeguard/-/codeguard-1.0.0.tgz","fileCount":242,"integrity":"sha512-IAKYSpo3XNNKAnRanEg2Lhc5mPrQYXpffM27QXx+WQWTXcVYW3ERQNV/G+6mMOPuruFkLTfI+P/vk+yfk/imqA==","signatures":[{"sig":"MEUCIDBmmGL3uhDgHSK0Gh7cF6t9KDjDNQAFYeSS7fl4pgSHAiEA+an2dnreZ4UEqwO/m3ordUYZBzx+Me/w73XL8CfAwjA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":97482462},"main":"dist/cli/index.js","type":"module","engines":{"node":">=18.0.0"},"scripts":{"dev":"tsx src/cli/index.ts","build":"tsc"},"_npmUser":{"name":"abhidobariya","email":"abhidobariya2004@gmail.com"},"_npmVersion":"11.3.0","description":"AI-powered local code guardian — detects bugs on every file save","directories":{},"_nodeVersion":"24.11.1","dependencies":{"ink":"^7.0.3","ora":"^9.4.0","chalk":"^5.6.2","react":"^19.2.6","dotenv":"^17.4.2","chokidar":"^5.0.0","ts-morph":"^28.0.0","commander":"^14.0.3","sqlite-vec":"^0.1.9","better-sqlite3":"^12.9.0","@google/generative-ai":"^0.24.1"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.0.0","typescript":"^6.0.3","@types/node":"^25.6.0","@types/react":"^19.2.14","@types/chokidar":"^1.7.5","@types/better-sqlite3":"^7.6.13"},"_npmOperationalInternal":{"tmp":"tmp/codeguard_1.0.0_1779018712307_0.7167886343057153","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@abhidobariya/codeguard","version":"1.0.3","description":"AI-powered local code guardian — detects bugs on every file save using local vector database and Gemini API","main":"dist/cli/index.js","bin":{"codeguard":"dist/cli/index.js"},"scripts":{"dev":"tsx src/cli/index.ts","build":"tsc"},"keywords":["ai","bug-detector","code-review","bug-detection","typescript","csharp","developer-tools","local-ai"],"author":{"name":"abhidobariya"},"license":"ISC","type":"module","devDependencies":{"@types/better-sqlite3":"^7.6.13","@types/chokidar":"^1.7.5","@types/node":"^25.6.0","@types/react":"^19.2.14","tsx":"^4.0.0","typescript":"^6.0.3"},"dependencies":{"@google/generative-ai":"^0.24.1","better-sqlite3":"^12.9.0","chalk":"^5.6.2","chokidar":"^5.0.0","commander":"^14.0.3","dotenv":"^17.4.2","ink":"^7.0.3","openai":"^6.39.0","ora":"^9.4.0","react":"^19.2.6","sqlite-vec":"^0.1.9","ts-morph":"^28.0.0"},"engines":{"node":">=18.0.0"},"_id":"@abhidobariya/codeguard@1.0.3","_nodeVersion":"24.11.1","_npmVersion":"11.3.0","dist":{"integrity":"sha512-bCcA+bvipKTa7SO7wEF91TCdmfc0u9ZXkuoZdzD+F+ZviXt5WsKqHEpNRRgqtKST07UI3OjvsNSRa17Sbyit7g==","shasum":"3dfe61c9568e6a8587b408303cecf554ea86de1a","tarball":"https://registry.npmjs.org/@abhidobariya/codeguard/-/codeguard-1.0.3.tgz","fileCount":244,"unpackedSize":97490309,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGmoLGzy/luPjlBuIMiW6lbZIL+sBYP7DWzABSAbss2wAiEAwChcL+kat6bo2XnG20B24COmobtSGpg7LVJdoAtTpMk="}]},"_npmUser":{"name":"abhidobariya","email":"abhidobariya2004@gmail.com"},"directories":{},"maintainers":[{"name":"abhidobariya","email":"abhidobariya2004@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/codeguard_1.0.3_1779765194644_0.9368501891312493"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-17T11:51:52.182Z","modified":"2026-05-26T03:13:15.423Z","1.0.0":"2026-05-17T11:51:53.418Z","1.0.3":"2026-05-26T03:13:15.324Z"},"author":{"name":"abhidobariya"},"license":"ISC","keywords":["ai","bug-detector","code-review","bug-detection","typescript","csharp","developer-tools","local-ai"],"description":"AI-powered local code guardian — detects bugs on every file save using local vector database and Gemini API","maintainers":[{"name":"abhidobariya","email":"abhidobariya2004@gmail.com"}],"readme":"# 🛡️ Bug Detector\n\n> AI-powered local code guardian that detects bugs on every file save — using a local vector database and Gemini API.\n\n## What it does\n\nBug Detector watches your project files. Every time you save a file, it:\n\n1. Re-indexes the changed code into a local vector database\n2. Finds related code across your project using semantic search\n3. Detects all chunks changed in your current session\n4. Sends targeted context to Gemini AI for analysis\n5. Reports bugs, affected areas, and suggestions instantly\n\nNo cloud storage. No sending your entire codebase anywhere. Everything runs locally except the final Gemini analysis call.\n\n---\n\n## Features\n\n- 🔍 **Bug detection** — finds logic bugs, type mismatches, and potential crashes\n- 🗺️ **Blast radius** — shows which other files your change could affect\n- 🔄 **Session-aware** — tracks all changes made in the last 2 hours, not just the last save\n- 🏗️ **Cross-stack detection** — matches C# backend routes with TypeScript frontend fetch calls\n- 💾 **Local vector DB** — SQLite + embeddings, runs entirely on your PC\n- 🤖 **Local model fallback** — use deepseek-coder via Ollama instead of Gemini (no API cost)\n- 📊 **Terminal dashboard** — live updating UI with `--dashboard` flag\n- 🔷 **TypeScript + C#** — supports both languages in the same project\n\n---\n\n## Requirements\n\n- Node.js 18+\n- [Ollama](https://ollama.com) — installed automatically on first run\n- Gemini API key — free at [aistudio.google.com](https://aistudio.google.com)\n- .NET SDK — only needed if you have C# files\n\n---\n\n## Installation\n\n```bash\nnpm install -g bug-detector\n```\n\n---\n\n## Setup\n\n**1. Create a `.env` file in your project root:**\n\n```env\nGEMINI_API_KEY=your_gemini_api_key_here\nCODEGUARD_MODE=gemini\n```\n\nGet your free Gemini API key at [aistudio.google.com](https://aistudio.google.com).\n\n**Or use DeepSeek (recommended — better free tier):**\n\n```env\nDEEPSEEK_API_KEY=your_deepseek_api_key_here\nCODEGUARD_MODE=deepseek\n```\n\nGet your free DeepSeek API key at [platform.deepseek.com](https://platform.deepseek.com).\n\n**2. Index your project:**\n\n```bash\ncodeguard init\n```\n\nThis scans your project, generates embeddings, and builds a local vector database in `.codeguard/db.sqlite`.\n\nAdd `.codeguard/` and `.env` to your `.gitignore`.\n\n**3. Start watching:**\n\n```bash\ncodeguard watch\n```\n\nOr with the live dashboard:\n\n```bash\ncodeguard watch --dashboard\n```\n\nNow save any file and Bug Detector will analyse it instantly.\n\n---\n\n## Commands\n\n| Command | Description |\n|---|---|\n| `codeguard init` | Index your project for the first time |\n| `codeguard watch` | Watch files and detect bugs on save |\n| `codeguard watch --dashboard` | Watch with live terminal dashboard |\n| `codeguard status` | Show indexed files and stored routes |\n\n---\n\n## Analysis output\n\n```\n─────────────────────────────────\n  CODEGUARD ANALYSIS REPORT\n─────────────────────────────────\n  🔴 Line 42: Missing null check before accessing user.profile\n  🟡 Line 67: This function mutates the input array directly\n\n  ⚠ Affected areas:\n    src/api/user.ts → getProfile\n    Reason: Calls getUserById which may return null\n\n  💡 Suggestions:\n    • Add null guard before accessing user.profile\n    • Consider returning a copy of the array instead\n─────────────────────────────────\n```\n\nSeverity levels:\n- 🔴 **Error** — likely to cause a crash or incorrect behavior\n- 🟡 **Warning** — potential issue, worth reviewing\n- 🔵 **Info** — improvement suggestion\n\n---\n\n## Using local model (no API cost)\n\nIf you want to run fully offline without Gemini API:\n\n```env\nCODEGUARD_MODE=local\n```\n\nThis uses `deepseek-coder` via Ollama. Quality is lower than Gemini but works with no internet and no API limits.\n\nPull the model first:\n\n```bash\nollama pull deepseek-coder\n```\n\n---\n\n## How it works\n\n```\ncodeguard init\n      ↓\nScans project → extracts functions/classes/routes\n      ↓\nGenerates embeddings via Ollama (local, no cost)\n      ↓\nStores in SQLite vector database (.codeguard/db.sqlite)\n      ↓\nBuilds dependency graph (what imports what)\n\nOn every file save:\n      ↓\nRe-indexes changed file\n      ↓\nFetches all chunks changed in last 2 hours\n      ↓\nSemantic search for related context\n      ↓\nSends to Gemini → bug report in terminal\n```\n\n---\n\n## Supported languages\n\n| Language | Parser | Features |\n|---|---|---|\n| TypeScript / TSX | ts-morph | Functions, classes, interfaces, hooks, fetch calls |\n| C# | Roslyn | Classes, methods, interfaces, enums, HTTP routes |\n\n---\n\n## Cross-stack detection\n\nFor full-stack projects with a C# backend and TypeScript frontend, Bug Detector matches your API routes with your frontend fetch calls and warns you about mismatches:\n\n```\n⚠ Cross-stack mismatch:\n  [GET] /api/users → UserController.GetUsers()\n  Frontend: src/api/users.ts calls /api/user (missing 's')\n```\n\n---\n\n## gitignore\n\nAdd these to your `.gitignore`:\n\n```\n.codeguard/\n.env\n```\n\n---\n\n## Tech stack\n\n- **Embeddings** — Ollama + nomic-embed-text (local, free)\n- **Vector search** — SQLite + sqlite-vec\n- **TypeScript parser** — ts-morph\n- **C# parser** — Roslyn (.NET)\n- **AI analysis** — Gemini API / deepseek-coder\n- **File watching** — chokidar\n- **Dashboard** — ink (React for terminal)\n\n---\n\n## License\n\nMIT\n","readmeFilename":"README.md"}