Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dist/
build/
*.egg
.eggs/
.gemini/

# Virtual environments
.venv/
Expand Down
7 changes: 6 additions & 1 deletion README.hi-IN.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ AI कोडिंग टूल्स हर टास्क पर आपका
## त्वरित शुरुआत

```bash
# Python का उपयोग करके (अनुशंसित)
pip install code-review-graph # या: pipx install code-review-graph

# Node.js का उपयोग करके
npm install -g code-review-graph

code-review-graph install # सभी समर्थित प्लेटफ़ॉर्म को स्वचालित रूप से पहचानता और कॉन्फ़िगर करता है
code-review-graph build # अपना कोडबेस पार्स करें
```
Expand Down Expand Up @@ -317,6 +322,6 @@ MIT। [LICENSE](LICENSE) देखें।
<p align="center">
<br>
<a href="https://code-review-graph.com">code-review-graph.com</a><br><br>
<code>pip install code-review-graph && code-review-graph install</code><br>
<code>pip install code-review-graph # या: npm install -g code-review-graph<br>code-review-graph install</code><br>
<sub>Codex, Claude Code, Cursor, Windsurf, Zed, Continue, OpenCode, Antigravity, और Kiro के साथ काम करता है</sub>
</p>
7 changes: 6 additions & 1 deletion README.ja-JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ AIコーディングツールはタスクのたびにコードベース全体を
## クイックスタート

```bash
# Pythonを使用 (推奨)
pip install code-review-graph # または: pipx install code-review-graph

# Node.jsを使用
npm install -g code-review-graph

code-review-graph install # 対応プラットフォームを自動検出して設定
code-review-graph build # コードベースを解析
```
Expand Down Expand Up @@ -319,6 +324,6 @@ MIT。詳細は [LICENSE](LICENSE) を参照してください。
<p align="center">
<br>
<a href="https://code-review-graph.com">code-review-graph.com</a><br><br>
<code>pip install code-review-graph && code-review-graph install</code><br>
<code>pip install code-review-graph # または: npm install -g code-review-graph<br>code-review-graph install</code><br>
<sub>Codex、Claude Code、Cursor、Windsurf、Zed、Continue、OpenCode、Antigravity、Kiroに対応</sub>
</p>
7 changes: 6 additions & 1 deletion README.ko-KR.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ AI 코딩 도구는 매 작업마다 전체 코드베이스를 다시 읽습니
## 빠른 시작

```bash
# Python 사용 (권장)
pip install code-review-graph # 또는: pipx install code-review-graph

# Node.js 사용
npm install -g code-review-graph

code-review-graph install # 지원되는 모든 플랫폼을 자동 감지하고 설정
code-review-graph build # 코드베이스 파싱
```
Expand Down Expand Up @@ -319,6 +324,6 @@ MIT. [LICENSE](LICENSE)를 참조하세요.
<p align="center">
<br>
<a href="https://code-review-graph.com">code-review-graph.com</a><br><br>
<code>pip install code-review-graph && code-review-graph install</code><br>
<code>pip install code-review-graph # 또는: npm install -g code-review-graph<br>code-review-graph install</code><br>
<sub>Codex, Claude Code, Cursor, Windsurf, Zed, Continue, OpenCode, Antigravity, Kiro에서 사용 가능</sub>
</p>
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ AI coding tools re-read your entire codebase on every task. `code-review-graph`
## Quick Start

```bash
# Using Python (recommended)
pip install code-review-graph # or: pipx install code-review-graph

# Using Node.js
npm install -g code-review-graph

code-review-graph install # auto-detects and configures all supported platforms
code-review-graph build # parse your codebase
```
Expand Down Expand Up @@ -531,6 +536,6 @@ MIT. See [LICENSE](LICENSE).
<p align="center">
<br>
<a href="https://code-review-graph.com">code-review-graph.com</a><br><br>
<code>pip install code-review-graph && code-review-graph install</code><br>
<code>pip install code-review-graph # or: npm install -g code-review-graph<br>code-review-graph install</code><br>
<sub>Works with Codex, Claude Code, Cursor, Windsurf, Zed, Continue, OpenCode, Antigravity, Gemini CLI, Qwen, Qoder, Kiro, GitHub Copilot, and GitHub Copilot CLI</sub>
</p>
7 changes: 6 additions & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ AI 编码工具在每次任务中都会重新读取整个代码库。`code-revie
## 快速开始

```bash
# 使用 Python (推荐)
pip install code-review-graph # 或: pipx install code-review-graph

# 使用 Node.js
npm install -g code-review-graph

code-review-graph install # 自动检测并配置所有支持的平台
code-review-graph build # 解析代码库
```
Expand Down Expand Up @@ -317,6 +322,6 @@ MIT。详见 [LICENSE](LICENSE)。
<p align="center">
<br>
<a href="https://code-review-graph.com">code-review-graph.com</a><br><br>
<code>pip install code-review-graph && code-review-graph install</code><br>
<code>pip install code-review-graph # 或: npm install -g code-review-graph<br>code-review-graph install</code><br>
<sub>支持 Codex、Claude Code、Cursor、Windsurf、Zed、Continue、OpenCode、Antigravity 和 Kiro</sub>
</p>
76 changes: 76 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env node

/**
* Node.js wrapper for code-review-graph Python CLI.
* This forwards all commands and arguments to the underlying Python implementation.
*/

const { spawn } = require('child_process');
const path = require('path');
const fs = require('fs');

function findPythonCLI() {
// 1. Check if the command is already in PATH (e.g. installed via global pip)
// We don't use 'which' here to avoid platform issues, instead we try to spawn it.

// 2. Check for a local virtualenv in the package directory
// This is where postinstall might have installed it
const packageRoot = path.join(__dirname, '..');
const venvBin = process.platform === 'win32'
? path.join(packageRoot, '.venv', 'Scripts', 'code-review-graph.exe')
: path.join(packageRoot, '.venv', 'bin', 'code-review-graph');

if (fs.existsSync(venvBin)) {
return venvBin;
}

// 3. Fallback to just 'code-review-graph' assuming it's in PATH
return 'code-review-graph';
}

const cliPath = findPythonCLI();
const args = process.argv.slice(2);

// Handle the case where the CLI isn't found at all
// We'll try to run it; if it fails with ENOENT, we'll give a helpful message.

const child = spawn(cliPath, args, {
stdio: 'inherit',
env: {
...process.env,
// Ensure Python doesn't buffer output, which is critical for MCP server mode
PYTHONUNBUFFERED: '1'
}
});

child.on('error', (err) => {
if (err.code === 'ENOENT') {
console.error('\x1b[31mError: code-review-graph Python core not found.\x1b[0m');
console.error('Please ensure you have Python 3.10+ installed.');
console.error('Try running: npm install (to trigger postinstall setup)');
console.error('\nIf that fails, you can install the core manually via:');
console.error(' pip install code-review-graph');
process.exit(1);
} else {
console.error('Error spawning code-review-graph:', err.message);
process.exit(1);
}
});

child.on('exit', (code, signal) => {
if (code !== null) {
process.exit(code);
} else if (signal) {
process.kill(process.pid, signal);
}
});

// Forward signals to the child process
const signals = ['SIGINT', 'SIGTERM', 'SIGHUP'];
signals.forEach(sig => {
process.on(sig, () => {
if (child.connected) {
child.kill(sig);
}
});
});
46 changes: 46 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "code-review-graph",
"version": "2.3.3",
"description": "Persistent incremental knowledge graph for token-efficient, context-aware code reviews. Node.js wrapper for the Python CLI.",
"main": "bin/cli.js",
"bin": {
"code-review-graph": "bin/cli.js",
"crg": "bin/cli.js"
},
"scripts": {
"postinstall": "node scripts/npm-postinstall.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/tirth8205/code-review-graph.git"
},
"keywords": [
"code-review",
"knowledge-graph",
"tree-sitter",
"mcp",
"ai-agent",
"static-analysis"
],
"author": "Tirth",
"license": "MIT",
"bugs": {
"url": "https://github.com/tirth8205/code-review-graph/issues"
},
"homepage": "https://github.com/tirth8205/code-review-graph#readme",
"engines": {
"node": ">=16.0.0"
},
"files": [
"bin",
"scripts",
"code_review_graph",
"pyproject.toml",
"README.md",
"LICENSE",
"uv.lock",
"skills",
"hooks"
]
}
72 changes: 72 additions & 0 deletions scripts/npm-postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* NPM Post-install script for code-review-graph.
* Sets up the Python environment and installs the core package.
*/

const { execSync, spawnSync } = require('child_process');
const path = require('path');
const fs = require('fs');

const packageRoot = path.join(__dirname, '..');
const venvDir = path.join(packageRoot, '.venv');

console.log('\x1b[36mSetting up code-review-graph Python core...\x1b[0m');

function run(cmd, args, options = {}) {
const result = spawnSync(cmd, args, {
stdio: 'inherit',
shell: true,
cwd: packageRoot,
...options
});
if (result.status !== 0) {
throw new Error(`Command failed: ${cmd} ${args.join(' ')}`);
}
}

try {
// 1. Check for Python 3.10+
try {
const pyVersion = execSync('python3 --version').toString().trim();
console.log(`Found ${pyVersion}`);
} catch (e) {
console.error('\x1b[31mError: Python 3 not found.\x1b[0m');
console.error('code-review-graph requires Python 3.10 or higher.');
process.exit(1);
}

// 2. Check for uv (faster) or fallback to venv + pip
let hasUv = false;
try {
execSync('uv --version');
hasUv = true;
console.log('Found uv, using it for faster setup...');
} catch (e) {}

if (hasUv) {
run('uv', ['sync', '--no-dev']);
} else {
// Standard venv + pip
if (!fs.existsSync(venvDir)) {
console.log('Creating virtual environment...');
run('python3', ['-m', 'venv', '.venv']);
}

const pipPath = process.platform === 'win32'
? path.join(venvDir, 'Scripts', 'pip')
: path.join(venvDir, 'bin', 'pip');

console.log('Installing Python dependencies...');
run(pipPath, ['install', '--upgrade', 'pip']);
run(pipPath, ['install', '.']);
}

console.log('\x1b[32m\nSuccessfully set up code-review-graph!\x1b[0m');
console.log('You can now run it using: code-review-graph --help');

} catch (error) {
console.error('\x1b[31m\nFailed to set up Python environment.\x1b[0m');
console.error(error.message);
console.error('\nYou can still use the tool if you install it manually via pip:');
console.error(' pip install code-review-graph');
}