{"_id":"@bloom-and-co/code-review","_rev":"3-d6388e96ab4e40ec48d12827f75aa45c","name":"@bloom-and-co/code-review","dist-tags":{"latest":"1.2.0"},"versions":{"1.1.2":{"name":"@bloom-and-co/code-review","version":"1.1.2","keywords":["code-review","ai","cli","git","bloom","gemini","reviewer"],"author":{"name":"Bloom&Co., Inc."},"license":"MIT","_id":"@bloom-and-co/code-review@1.1.2","maintainers":[{"name":"masuidrive","email":"masui@masuidrive.jp"}],"homepage":"https://github.com/bloom-and-co/code-review#readme","bugs":{"url":"https://github.com/bloom-and-co/code-review/issues"},"bin":{"code-review":"dist/index.js"},"dist":{"shasum":"1862fcec38e0e10756347a1859f44995739e90b7","tarball":"https://registry.npmjs.org/@bloom-and-co/code-review/-/code-review-1.1.2.tgz","fileCount":47,"integrity":"sha512-2JGMoOqYaNYbgk+Fou3gfxj9EPD1MkS4Psl1zU1nHtQ67YnMF+IGcBejsHdVEDD4LphIe00c70EiNSiX8MEDwA==","signatures":[{"sig":"MEYCIQCbxx8iY6KFaaEqh2e01XdTwsjWtVB7E9Q9zbubp4YQygIhAMqI6NwfIp8eVIgJMH/EaG+D6r3xIXDNnaRXzdco0f/D","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":115308},"main":"dist/index.js","types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"6d19f507e3ad74d2286e66744443992bfabd3f63","scripts":{"dev":"tsx src/index.ts","lint":"eslint src/**/*.ts","build":"tsc && chmod +x dist/index.js","start":"node dist/index.js","format":"prettier --write src/**/*.ts","prepare":"npm run build"},"_npmUser":{"name":"masuidrive","actor":{"name":"masuidrive","type":"user","email":"masui@masuidrive.jp"},"email":"masui@masuidrive.jp"},"repository":{"url":"git+https://github.com/bloom-and-co/code-review.git","type":"git"},"_npmVersion":"10.9.0","description":"AI-powered code review CLI tool","directories":{},"_nodeVersion":"22.12.0","dependencies":{"ai":"^4.0.0","zod":"^3.23.8","dotenv":"^16.4.5","ignore":"^6.0.2","js-yaml":"^4.1.0","commander":"^12.1.0","parse-diff":"^0.11.1","simple-git":"^3.27.0","@ai-sdk/google":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","eslint":"^9.17.0","prettier":"^3.4.2","typescript":"^5.7.2","@types/node":"^22.10.2","@types/js-yaml":"^4.0.9","@typescript-eslint/parser":"^8.18.0","@typescript-eslint/eslint-plugin":"^8.18.0"},"_npmOperationalInternal":{"tmp":"tmp/code-review_1.1.2_1750661753873_0.6241520104109339","host":"s3://npm-registry-packages-npm-production"}},"1.1.3":{"name":"@bloom-and-co/code-review","version":"1.1.3","keywords":["code-review","ai","cli","git","bloom","gemini","reviewer"],"author":{"name":"Bloom&Co., Inc."},"license":"MIT","_id":"@bloom-and-co/code-review@1.1.3","maintainers":[{"name":"masuidrive","email":"masui@masuidrive.jp"}],"homepage":"https://github.com/bloom-and-co/code-review#readme","bugs":{"url":"https://github.com/bloom-and-co/code-review/issues"},"bin":{"code-review":"dist/index.js"},"dist":{"shasum":"76b111f03e9e7b5b30e917bfb05d6bd452e5fdf6","tarball":"https://registry.npmjs.org/@bloom-and-co/code-review/-/code-review-1.1.3.tgz","fileCount":54,"integrity":"sha512-NdE537leOFLgxHBfyVsBSIfGC5UNik9Ozslczbtiytku3pcbEB7hXg5l0RharbV24fdySXjr5evXU+sIydpfag==","signatures":[{"sig":"MEQCIA9MzqbRCd/BaCcLuwAa9qzCsxnRq/cqFeNDtoyh53fbAiBp7DlhzE91TBO8U0x8RwWCxrZKRJEtEdIh5jflTjKCIQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":187096},"main":"dist/index.js","types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"e22f5e6653c9f10bead35cf76ba3ddb310fc2373","scripts":{"dev":"tsx src/index.ts","lint":"eslint src/**/*.ts","build":"tsc && chmod +x dist/index.js","start":"node dist/index.js","format":"prettier --write src/**/*.ts","prepare":"npm run build"},"_npmUser":{"name":"masuidrive","actor":{"name":"masuidrive","type":"user","email":"masui@masuidrive.jp"},"email":"masui@masuidrive.jp"},"repository":{"url":"git+https://github.com/bloom-and-co/code-review.git","type":"git"},"_npmVersion":"10.9.0","description":"AI-powered code review CLI tool","directories":{},"_nodeVersion":"22.12.0","dependencies":{"ai":"^4.0.0","zod":"^3.23.8","dotenv":"^16.4.5","ignore":"^6.0.2","js-yaml":"^4.1.0","commander":"^12.1.0","fast-glob":"^3.3.3","parse-diff":"^0.11.1","simple-git":"^3.27.0","@ai-sdk/google":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","eslint":"^9.17.0","prettier":"^3.4.2","typescript":"^5.7.2","@types/node":"^22.10.2","@types/js-yaml":"^4.0.9","@typescript-eslint/parser":"^8.18.0","@typescript-eslint/eslint-plugin":"^8.18.0"},"_npmOperationalInternal":{"tmp":"tmp/code-review_1.1.3_1751341617367_0.4848265217067198","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@bloom-and-co/code-review","version":"1.2.0","description":"AI-powered code review CLI tool","main":"dist/index.js","bin":{"code-review":"dist/index.js"},"scripts":{"build":"tsc && chmod +x dist/index.js","dev":"tsx src/index.ts","start":"node dist/index.js","lint":"eslint src/**/*.ts","format":"prettier --write src/**/*.ts","prepare":"npm run build"},"keywords":["code-review","ai","cli","git","bloom","gemini","reviewer"],"author":{"name":"Bloom&Co., Inc."},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/bloom-and-co/code-review.git"},"homepage":"https://github.com/bloom-and-co/code-review#readme","bugs":{"url":"https://github.com/bloom-and-co/code-review/issues"},"dependencies":{"@ai-sdk/anthropic":"^1.2.12","@ai-sdk/google":"^1.0.0","@ai-sdk/openai":"^1.3.22","ai":"^4.0.0","commander":"^12.1.0","dotenv":"^16.4.5","fast-glob":"^3.3.3","ignore":"^6.0.2","js-yaml":"^4.1.0","parse-diff":"^0.11.1","simple-git":"^3.27.0","zod":"^3.23.8"},"devDependencies":{"@types/js-yaml":"^4.0.9","@types/node":"^22.10.2","@typescript-eslint/eslint-plugin":"^8.18.0","@typescript-eslint/parser":"^8.18.0","eslint":"^9.17.0","prettier":"^3.4.2","tsx":"^4.19.2","typescript":"^5.7.2"},"engines":{"node":">=18.0.0"},"_id":"@bloom-and-co/code-review@1.2.0","gitHead":"dabe908f507fcc1e6f72d92ae785623d0c503443","types":"./dist/index.d.ts","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-40bDZ3WKY3srCF1bXb3axEWS/S5jT82z0Gn3NO+OiKTzjVRHV7AvzPJBtTqSgL1ryblBWZfJwcf0WJBPBSSgrQ==","shasum":"39f27fc1f4d9567deac3f59cb3d285ba561754bd","tarball":"https://registry.npmjs.org/@bloom-and-co/code-review/-/code-review-1.2.0.tgz","fileCount":60,"unpackedSize":220088,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBDwDZLOvlb1H0YFAdC0jxIjJMW90/bbSAF6JCnaLp7dAiEArG7fulBz4Ql2OLkMmzA3uL+1o1wJDkW+ymqjZdVRCGI="}]},"_npmUser":{"name":"masuidrive","email":"masui@masuidrive.jp","actor":{"name":"masuidrive","email":"masui@masuidrive.jp","type":"user"}},"directories":{},"maintainers":[{"name":"masuidrive","email":"masui@masuidrive.jp"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/code-review_1.2.0_1751345125755_0.35242734623894756"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-23T06:55:53.732Z","modified":"2025-07-01T04:45:26.516Z","1.1.2":"2025-06-23T06:55:54.149Z","1.1.3":"2025-07-01T03:46:57.544Z","1.2.0":"2025-07-01T04:45:25.959Z"},"bugs":{"url":"https://github.com/bloom-and-co/code-review/issues"},"author":{"name":"Bloom&Co., Inc."},"license":"MIT","homepage":"https://github.com/bloom-and-co/code-review#readme","keywords":["code-review","ai","cli","git","bloom","gemini","reviewer"],"repository":{"type":"git","url":"git+https://github.com/bloom-and-co/code-review.git"},"description":"AI-powered code review CLI tool","maintainers":[{"name":"masuidrive","email":"masui@masuidrive.jp"}],"readme":"# Code Review\n\n[Japanese ver.](README.ja.md)\n\nAI-powered code review CLI tool that helps developers get comprehensive code reviews by combining:\n- **Your task description** (what you're trying to achieve)\n- **Your code changes** (Git diff)\n- **Project context** (file structure and related files)\n\n## What is this tool?\n\nCode Review uses AI to review your code changes in the context of what you're trying to accomplish. Unlike simple linting tools, it understands your intent from a \"ticket\" (task description) and reviews whether your implementation correctly addresses that goal.\n\n### Key Features\n\n- **Context-aware reviews**: Reviews code based on your task description, not just syntax\n- **Two-phase analysis**: First identifies relevant files, then performs detailed review\n- **Security & performance focus**: Catches potential vulnerabilities and performance issues\n- **Multilingual support**: Reviews in your preferred language\n\n## Installation\n\n```bash\n# Install via npm\nnpm install -g @bloom-and-co/code-review\n\n# Or install development version locally\ngit clone <repository-url>\ncd code-review\nnpm install\nnpm run build\nnpm link\n```\n\n## Setup\n\n1. Get an API key from one of the supported providers:\n   - **Google AI (Gemini)**: [Google AI Studio](https://makersuite.google.com/app/apikey)\n   - **OpenAI (GPT-4o)**: [OpenAI Platform](https://platform.openai.com/api-keys)\n   - **Anthropic (Claude)**: [Anthropic Console](https://console.anthropic.com/account/keys)\n\n2. Set environment variables\n\n   **Set the API key for your chosen provider:**\n   - `GOOGLE_GENERATIVE_AI_API_KEY` - For Google AI (Gemini)\n   - `OPENAI_API_KEY` - For OpenAI (GPT-4o)\n   - `ANTHROPIC_API_KEY` - For Anthropic (Claude)\n\n   You have two options:\n   \n   **Option 1: Export directly**\n   ```bash\n   # For Google AI\n   export GOOGLE_GENERATIVE_AI_API_KEY=\"your-api-key-here\"\n   \n   # For OpenAI\n   export OPENAI_API_KEY=\"your-api-key-here\"\n   \n   # For Anthropic\n   export ANTHROPIC_API_KEY=\"your-api-key-here\"\n   ```\n   \n   **Option 2: Use .env file**\n   ```bash\n   cp .env.sample .env\n   # Edit .env file to set API key\n   # Then use --dotenv option when running the tool\n   ```\n\n## Configuration\n\nYou can override default settings with a JSON or YAML configuration file. The tool automatically looks for:\n- `code-review.config.yaml` (or `.yml`)\n- `code-review.config.json`\n- `.code-review.yaml` (or `.yml`)\n- `.code-review.json`\n\n```bash\n# Copy sample configuration file\ncp code-review.config.example.yaml code-review.config.yaml\n```\n\n### Configuration Priority\n\n1. Command line options (highest priority)\n2. Configuration file\n3. Default values\n\n### Configuration File Example (YAML)\n\n```yaml\ngit:\n  defaultDiffRange: \"\"  # Empty string = working directory changes (pre-commit)\n\nmodels:\n  # You can use models from any supported provider:\n  # Google AI: gemini-2.5-flash, gemini-2.5-pro\n  # OpenAI: gpt-4o\n  # Anthropic: claude-3-7-sonnet-latest, claude-3-7-haiku-latest\n  analyze: gemini-2.5-flash\n  review: gemini-2.5-pro\n\nprompts:\n  analyzeMaxChars: 500000\n  reviewMaxChars: 500000\n  analyze: |\n    Focus on security and performance-related files when listing additional files needed for review.\n  review: |\n    Focus on:\n    1. Security vulnerabilities\n    2. Performance issues\n    3. Code readability\n    4. Maintainability\n    \n    Mark issues with severity levels.\n```\n\n## How it works\n\n1. **You provide a ticket file** - A text file describing what you're implementing or fixing\n2. **The tool analyzes your Git changes** - Compares your code changes against your stated goal\n3. **AI performs a two-phase review**:\n   - Phase 1: Identifies additional files needed for context\n   - Phase 2: Provides detailed review with specific suggestions\n\n## Usage\n\n### Basic Usage\n\nFirst, create a \"ticket\" file describing your task:\n\n```bash\n# Create a ticket file\necho \"Add user authentication with JWT tokens\" > ticket.md\n\n# Run the review on your staged changes\nnpx @bloom-and-co/code-review --ticket ticket.md\n```\n\n### What is a \"ticket\"?\n\nA ticket is a text file containing your task description. It can be:\n- A copy of your Jira/GitHub issue\n- A simple description of what you're implementing\n- Technical requirements or specifications\n- Bug report you're fixing\n\nExample ticket.md:\n```markdown\n## Task: Add User Authentication\n\nImplement JWT-based authentication with the following requirements:\n- User login with email/password\n- Token expiration after 24 hours\n- Refresh token mechanism\n- Secure password hashing with bcrypt\n```\n\n### Common Use Cases\n\n```bash\n# Review changes before committing (default)\nnpx @bloom-and-co/code-review --ticket ticket.md\n\n# Using .env file for API key\nnpx @bloom-and-co/code-review --ticket ticket.md --dotenv\n\n# Review a specific commit\nnpx @bloom-and-co/code-review --ticket ticket.md --git-diff HEAD~1\n\n# Review changes between branches\nnpx @bloom-and-co/code-review --ticket ticket.md --git-diff main..feature-branch\n\n# Include specific files for context\nnpx @bloom-and-co/code-review --ticket ticket.md --add-files \"src/config.ts,src/types.ts\"\n\n# Include files using wildcards\nnpx @bloom-and-co/code-review --ticket ticket.md --add-files \"src/**/*.ts,docs/**/*.md\"\n\n# Review with custom language output\nnpx @bloom-and-co/code-review --ticket ticket.md --language \"日本語\"\n\n# Use different AI providers\n# OpenAI GPT-4o\nnpx @bloom-and-co/code-review --ticket ticket.md --analyze-model gpt-4o --review-model gpt-4o\n\n# Anthropic Claude 3.7 Sonnet\nnpx @bloom-and-co/code-review --ticket ticket.md --analyze-model claude-3-7-sonnet-latest --review-model claude-3-7-sonnet-latest\n\n# Google Gemini (default)\nnpx @bloom-and-co/code-review --ticket ticket.md --analyze-model gemini-2.5-flash --review-model gemini-2.5-pro\n\n# Exclude specific files from diff (e.g., exclude generated files)\nnpx @bloom-and-co/code-review --ticket ticket.md --ignorefiles \"*.generated.ts,build/*\"\n\n# Disable default ignore patterns to review all files\nnpx @bloom-and-co/code-review --ticket ticket.md --ignorefiles \"\"\n```\n\n### Options\n\n| Option | Short | Description | Default |\n|--------|-------|-------------|---------|\n| `--ticket` | `-t` | Path to ticket/task description file (required) | - |\n| `--config` | `-c` | Path to configuration file (JSON/YAML) | - |\n| `--git-diff` | `-g` | Git diff range to review | `\"\"` (working directory) |\n| `--no-diff` | - | Skip git diff | - |\n| `--all-files` | - | Include all changed files and skip analyze phase | - |\n| `--add-files` | - | Additional files to include in review (comma-separated, supports wildcards) | - |\n| `--dotenv` | - | Load environment variables from .env file | - |\n| `--debug` | - | Debug mode (show prompts and responses to LLM) | - |\n| `--language` | - | Specify language for review output | - |\n| `--analyze-model` | - | Model for analyze phase | `gemini-2.5-flash` |\n| `--review-model` | - | Model for review phase | `gemini-2.5-pro` |\n| `--analyze-prompt` | - | Custom prompt for analyze phase | - |\n| `--review-prompt` | - | Custom prompt for review phase | - |\n| `--analyze-max-chars` | - | Max characters for analyze prompt | `500000` |\n| `--review-max-chars` | - | Max characters for review prompt | `500000` |\n| `--ignorefiles` | - | File patterns to exclude from diff (comma-separated) | Excludes many lock files and build artifacts by default |\n\n### Why Git Diff?\n\nThe tool uses Git diff to:\n- Focus on what you actually changed\n- Understand the context of your modifications\n- Provide line-specific feedback\n- Ensure reviews are relevant to your current work\n\nBy default, it reviews your working directory changes (staged + unstaged), perfect for pre-commit reviews.\n\n### Examples\n\n#### Pre-commit review (most common)\n```bash\n# Review your changes before committing\nnpx @bloom-and-co/code-review --ticket ticket.md\n```\n\n#### Run with specific models\n```bash\n# Google Gemini models\nnpx @bloom-and-co/code-review \\\n  --ticket ticket.txt \\\n  --analyze-model \"gemini-2.5-flash\" \\\n  --review-model \"gemini-2.5-pro\"\n\n# OpenAI GPT-4o\nexport OPENAI_API_KEY=\"your-openai-key\"\nnpx @bloom-and-co/code-review \\\n  --ticket ticket.txt \\\n  --analyze-model \"gpt-4o\" \\\n  --review-model \"gpt-4o\"\n\n# Anthropic Claude\nexport ANTHROPIC_API_KEY=\"your-anthropic-key\"\nnpx @bloom-and-co/code-review \\\n  --ticket ticket.txt \\\n  --analyze-model \"claude-3-7-sonnet-latest\" \\\n  --review-model \"claude-3-7-sonnet-latest\"\n```\n\n#### Use custom prompts\n```bash\nnpx @bloom-and-co/code-review \\\n  --ticket ticket.txt \\\n  --analyze-prompt \"Focus on security issues\" \\\n  --review-prompt \"Emphasize performance problems\"\n```\n\n#### Review specific commit range\n```bash\n# Diff with latest commit\nnpx @bloom-and-co/code-review --ticket ticket.txt --git-diff HEAD~1\n\n# Diff between branches\nnpx @bloom-and-co/code-review --ticket ticket.txt --git-diff main..feature-branch\n\n# Review only staging area\nnpx @bloom-and-co/code-review --ticket ticket.txt --git-diff --cached\n```\n\n#### Specify configuration file\n```bash\nnpx @bloom-and-co/code-review --ticket ticket.txt --config my-config.yaml\n```\n\n#### Review all files without diff\n```bash\nnpx @bloom-and-co/code-review --ticket ticket.txt --no-diff --all-files\n```\n\n#### Run in debug mode\n```bash\nnpx @bloom-and-co/code-review --ticket ticket.txt --debug\n```\n\n#### Output review in Japanese\n```bash\nnpx @bloom-and-co/code-review --ticket ticket.txt --language \"日本語\"\n```\n\n## How the Review Process Works\n\n### Phase 1: Context Analysis\nThe AI first understands:\n- What you're trying to achieve (from ticket)\n- What files you've changed (from Git diff)\n- Your project structure\n- What additional files it needs to see (e.g., interfaces, configs)\n\n### Phase 2: Detailed Review\nWith full context, the AI:\n- Reviews if your changes achieve the stated goal\n- Checks for bugs, security issues, and performance problems\n- Suggests improvements and best practices\n- Highlights any missing implementations\n\n## Output Format\n\nThe output format depends on the prompts configured in your settings. By default, the tool provides a structured review in Markdown format, but the exact structure and content will vary based on:\n- Your language settings\n- Custom prompts in configuration\n- The AI model's interpretation\n\nTypical output structure:\n```markdown\n# Code Review Results\n\n## Summary\n[Overall assessment based on your ticket requirements]\n\n## Issues Found\n[Categorized by severity: Critical/High/Medium/Low]\n\n## Suggestions for Improvement\n[Recommendations for better implementation]\n```\n\n**Note**: The actual format and categories may differ based on your prompts and language settings.\n\nIn debug mode (`--debug`), additional information is displayed:\n- Full input prompts sent to LLM\n- Analyze phase response (JSON format with required files)\n- Input/output token counts for both phases\n- Any errors or truncation warnings\n\n## Development\n\n```bash\n# Development mode (run TypeScript directly)\nnpm run dev -- --ticket ticket.txt\n\n# Build\nnpm run build\n\n# Lint\nnpm run lint\n\n# Format\nnpm run format\n```\n\n## Best Practices\n\n### Writing Good Tickets\n\nThe quality of the review depends on your ticket clarity:\n\n✅ **Good ticket**:\n```\nImplement user authentication with:\n- JWT tokens for stateless auth\n- Email/password login\n- Password reset functionality\n- Rate limiting on login attempts\n```\n\n❌ **Poor ticket**:\n```\nAdd login feature\n```\n\n### When to Use This Tool\n\n- **Before commits**: Catch issues early\n- **Before pull requests**: Ensure code quality\n- **During development**: Get feedback on approach\n- **Code refactoring**: Verify improvements\n- **Bug fixes**: Confirm the fix addresses the issue\n\n## Notes\n\n- Must be run within a Git repository\n- Binary files are automatically skipped\n- Files listed in .gitignore are excluded\n- Large files are automatically truncated\n- The AI reviews based on task context, not arbitrary instructions\n\n## Troubleshooting\n\n### API Key Error\n```\nError: GOOGLE_GENERATIVE_AI_API_KEY environment variable is not set\n```\n→ Either:\n  - Export the environment variable: `export GOOGLE_GENERATIVE_AI_API_KEY=\"your-key\"`\n  - Or use .env file with --dotenv option: `npx @bloom-and-co/code-review --ticket ticket.md --dotenv`\n\n### Git Repository Error\n```\nError: Current directory is not a git repository\n```\n→ Run within a Git repository\n\n### JSON Parse Error\n```\nError: Expected object, received array\n```\n→ LLM response is not in expected format. Check details with --debug option\n\n### Debug Mode\nFor detailed error information:\n```bash\nnpx @bloom-and-co/code-review --ticket ticket.txt --debug\n```\n\n---\n\n**IMPORTANT**: When updating this file, please also update corresponding content in other language versions (e.g., README.ja.md) to maintain consistency across all documentation.","readmeFilename":"README.md"}