From 0757f0c33d5744f4eb4e31393c2c4dc7e9cddb6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B1=84=EB=AC=B8=EC=B0=BD=40MBA?= Date: Thu, 18 Jun 2026 15:22:38 +0900 Subject: [PATCH] =?UTF-8?q?Open=20Code=20Review=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 38 ++++++++++++ install-ocr.ps1 | 149 ++++++++++++++++++++++++++++++++++++++++++++++++ install-ocr.sh | 141 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 328 insertions(+) create mode 100644 install-ocr.ps1 create mode 100644 install-ocr.sh diff --git a/README.md b/README.md index 60df53c..4ce6011 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ * **[Claude Code](https://code.claude.com/)** - Anthropic의 차세대 터미널 기반 대화형 AI 코딩 어시스턴트 CLI * **[Codex CLI](https://developers.openai.com/codex/cli)** - OpenAI의 공식 터미널 기반 로컬 대화형 코딩 에이전트 CLI * **[pi](https://pi.dev/)** - 대화형 CLI AI 코딩 어시스턴트 및 추천 플러그인 패키지 일괄 설치 도구 +* **[Open Code Review (ocr)](https://github.com/alibaba/open-code-review)** - AI 기반의 오픈소스 코드 리뷰 자동화 도구 --- @@ -123,6 +124,11 @@ curl -fsSL "https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-pi.sh?ref_type=heads" | bash ``` +* **Open Code Review (ocr):** + ```bash + curl -fsSL "https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-ocr.sh?ref_type=heads" | bash + ``` + --- ### 💻 Windows (PowerShell / CMD) @@ -284,6 +290,16 @@ $t="$env:TEMP\install-pi.ps1"; iwr -useb 'https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-pi.ps1' -OutFile $t; powershell -ExecutionPolicy Bypass -File $t ``` +* **Open Code Review (ocr):** + * **CMD 창에서 설치 시:** + ```cmd + powershell -ExecutionPolicy Bypass -c "[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; $t=\"$env:TEMP\install-ocr.ps1\"; iwr -useb 'https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-ocr.ps1' -OutFile $t; & $t" + ``` + * **파워쉘 창에서 설치 시:** + ```powershell + $t="$env:TEMP\install-ocr.ps1"; iwr -useb 'https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-ocr.ps1' -OutFile $t; powershell -ExecutionPolicy Bypass -File $t + ``` + --- ## 📖 도구별 상세 사용법 및 팁 @@ -617,6 +633,28 @@ pi --help # 도움말 및 사용 가능 커맨드 파악 pi list # 현재 설치 완료된 플러그인 에코시스템 목록 출력 ``` +#### 4.5. Open Code Review +Alibaba에서 개발한 AI 기반 오픈소스 코드 리뷰 자동화 도구입니다. 결정론적 엔지니어링 분석 기법과 LLM 에이전트의 강점을 하이브리드로 결합하여 코드 변경 사항의 컨텍스트를 깊이 있게 추적하고 리뷰 의견을 생성합니다. + +##### [주요 특징] +* **엔지니어링 & 에이전트 하이브리드** — 정밀한 파일 필터링과 라인 매칭 기술로 위치 오류(Position drift)를 차단하고, LLM 에이전트가 코드의 시맨틱 영역을 입체적으로 탐색합니다. +* **풍부한 컨텍스트 인지** — 단순한 diff 분석에 머물지 않고 전체 소스코드 검색, 연관 파일 분석 등을 병행합니다. +* **CI/CD 통합 지원** — GitHub Actions, GitLab CI 등 빌드 파이프라인에 이식하여 풀 리퀘스트(PR) 발생 시 자동으로 코드 리뷰가 가동되도록 연동할 수 있습니다. + +##### [사용을 위한 LLM 설정 (예: OpenAI)] +설치 후 사용하기 위해 LLM 엔드포인트 정보가 필요합니다. `ocr config` 명령어를 통해 환경을 구성합니다: +```bash +ocr config set llm.url "https://api.openai.com/v1" +ocr config set llm.auth_token "YOUR_API_KEY" +ocr config set llm.model "gpt-4o" +``` + +##### [ocr 기본 사용법] +```bash +ocr review --from main --to feature-branch # base 브랜치와 head 브랜치 간 변경 사항 리뷰 실행 +ocr config list # 현재 구성된 설정 목록 확인 +``` + --- _GitLab: https://gitlab.com/publicproj/install-sh_ diff --git a/install-ocr.ps1 b/install-ocr.ps1 new file mode 100644 index 0000000..d1fc47a --- /dev/null +++ b/install-ocr.ps1 @@ -0,0 +1,149 @@ +#Requires -Version 5.1 +<# +.SYNOPSIS + Installs Alibaba Open Code Review (ocr) for Windows. + +.DESCRIPTION + GitHub Releases에서 제공하는 Windows용 네이티브 바이너리(.exe)를 + 자동 감지된 아키텍처(AMD64 또는 ARM64)에 따라 다운로드하고 + $env:USERPROFILE\.local\bin\ocr.exe 경로에 설치합니다. + 공식 레포지토리: https://github.com/alibaba/open-code-review + +.EXAMPLE + .\install-ocr.ps1 +#> + +Set-StrictMode -Version Latest +$ErrorActionPreference = 'Stop' + +# HTTPS 다운로드를 위해 TLS 1.2+ 강제 설정 +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + +# ──────────────────────────────────────────── +# 상수 정의 +# ──────────────────────────────────────────── +$REPO = "alibaba/open-code-review" +$API_URL = "https://api.github.com/repos/$REPO/releases/latest" +$INSTALL_DIR = Join-Path $env:USERPROFILE ".local\bin" +$FALLBACK_VERSION = "v1.3.19" + +# ──────────────────────────────────────────── +# 유틸리티 함수 (영문 메시지 출력, 에러 방지용) +# ──────────────────────────────────────────── +function Info { Write-Host "[INFO] $args" -ForegroundColor Cyan } +function Warn { Write-Host "[WARN] $args" -ForegroundColor Yellow } +function Success { Write-Host "[OK] $args" -ForegroundColor Green } +function ErrExit { Write-Host "[ERROR] $args" -ForegroundColor Red; exit 1 } + +# ──────────────────────────────────────────── +# 아키텍처 감지 +# ──────────────────────────────────────────── +$arch = $env:PROCESSOR_ARCHITECTURE +Info "Detected CPU Architecture: $arch" + +$assetName = $null +if ($arch -eq "AMD64") { + $assetName = "opencodereview-windows-amd64.exe" +} elseif ($arch -eq "ARM64") { + $assetName = "opencodereview-windows-arm64.exe" +} else { + Warn "Unsupported architecture '$arch'. Falling back to AMD64." + $assetName = "opencodereview-windows-amd64.exe" +} + +# ──────────────────────────────────────────── +# 최신 릴리즈 태그 가져오기 +# ──────────────────────────────────────────── +$tag = $null +try { + Info "Fetching latest release tag from GitHub API..." + $response = Invoke-RestMethod -Uri $API_URL -TimeoutSec 10 + $tag = $response.tag_name +} catch { + Warn "Failed to retrieve the latest version from GitHub API. Using fallback version: $FALLBACK_VERSION" + $tag = $FALLBACK_VERSION +} + +if (-not $tag) { + $tag = $FALLBACK_VERSION +} + +$downloadUrl = "https://github.com/$REPO/releases/download/$tag/$assetName" +Info "Resolved download URL: $downloadUrl" + +# ──────────────────────────────────────────── +# 다운로드 및 설치 +# ──────────────────────────────────────────── +# 설치 폴더 생성 +if (-not (Test-Path $INSTALL_DIR)) { + New-Item -ItemType Directory -Path $INSTALL_DIR | Out-Null + Info "Created installation directory: $INSTALL_DIR" +} + +$tempFile = Join-Path $env:TEMP "ocr_temp.exe" +$destFile = Join-Path $INSTALL_DIR "ocr.exe" + +try { + Info "Downloading binary..." + # Invoke-WebRequest를 사용해 다운로드 진행 + Invoke-WebRequest -Uri $downloadUrl -OutFile $tempFile -UseBasicParsing + + # 다운로드 완료 후 복사 + if (Test-Path $destFile) { + Remove-Item $destFile -Force + } + Move-Item -Path $tempFile -Destination $destFile -Force + Success "Binary installed to $destFile" +} catch { + if (Test-Path $tempFile) { Remove-Item $tempFile -ErrorAction SilentlyContinue } + ErrExit "Failed to download or install the binary: $_" +} + +# ──────────────────────────────────────────── +# PATH 환경 변수 설정 +# ──────────────────────────────────────────── +$userPath = [System.Environment]::GetEnvironmentVariable('Path', 'User') +$normalizedInstallDir = $INSTALL_DIR.TrimEnd('\') + +# 현재 세션 PATH 확인 및 반영 +if ($env:Path -notlike "*$normalizedInstallDir*") { + $env:Path = "$normalizedInstallDir;$env:Path" + Info "Added $normalizedInstallDir to current session PATH." +} + +# 사용자 PATH 레지스트리 영구 등록 확인 +$pathList = $userPath -split ';' +$alreadyInPath = $false +foreach ($p in $pathList) { + if ($p.Trim().TrimEnd('\') -eq $normalizedInstallDir) { + $alreadyInPath = $true + break + } +} + +if (-not $alreadyInPath) { + $newUserPath = "$normalizedInstallDir;$userPath" + [System.Environment]::SetEnvironmentVariable('Path', $newUserPath, 'User') + Success "Added $normalizedInstallDir to User PATH environment variable permanently." + Info "Note: You need to restart your terminal/IDE to apply PATH changes." +} else { + Info "$normalizedInstallDir is already in User PATH." +} + +# ──────────────────────────────────────────── +# 설치 완료 정보 출력 +# ──────────────────────────────────────────── +Info "" +Info "==================================================" +Success "Open Code Review (ocr) installation complete!" +Info "==================================================" +Info "" +Info "How to run:" +Info " ocr review --from --to " +Info "" +Info "To configure LLM (e.g. OpenAI):" +Info ' ocr config set llm.url "https://api.openai.com/v1"' +Info ' ocr config set llm.auth_token "YOUR_API_KEY"' +Info ' ocr config set llm.model "gpt-4o"' +Info "" +Info "For more information, visit: https://github.com/alibaba/open-code-review" diff --git a/install-ocr.sh b/install-ocr.sh new file mode 100644 index 0000000..de05131 --- /dev/null +++ b/install-ocr.sh @@ -0,0 +1,141 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2086 + +# Alibaba Open Code Review (ocr) 설치 스크립트 +# +# macOS, Linux 환경에서 GitHub Releases에 배포된 최신 네이티브 바이너리를 다운로드하여 설치합니다. +# 공식 가이드: https://github.com/alibaba/open-code-review +# +# 지원 아키텍처: +# macOS : Apple Silicon (arm64), Intel (x86_64) +# Linux : x86_64 (amd64), ARM64 (aarch64) + +set -euo pipefail + +# ──────────────────────────────────────────── +# 상수 정의 +# ──────────────────────────────────────────── +REPO="alibaba/open-code-review" +API_URL="https://api.github.com/repos/${REPO}/releases/latest" +INSTALL_DIR="${HOME}/.local/bin" +FALLBACK_VERSION="v1.3.19" + +# ──────────────────────────────────────────── +# 유틸리티 함수 (모두 stderr 출력) +# ──────────────────────────────────────────── +info() { echo "[INFO] $*" >&2; } +warn() { echo "[WARN] $*" >&2; } +error() { echo "[ERROR] $*" >&2; exit 1; } +success() { echo "[OK] $*" >&2; } + +# ──────────────────────────────────────────── +# 필수 명령어 확인 +# ──────────────────────────────────────────── +for cmd in curl uname; do + command -v "$cmd" &>/dev/null || error "'$cmd' 명령어가 필요합니다." +done + +# ──────────────────────────────────────────── +# OS / 아키텍처 감지 및 파일명 결정 +# ──────────────────────────────────────────── +detect_platform() { + local os arch + os="$(uname -s)" + arch="$(uname -m)" + + case "$os" in + Darwin) + case "$arch" in + arm64) echo "opencodereview-darwin-arm64" ;; + x86_64) echo "opencodereview-darwin-amd64" ;; + *) error "지원하지 않는 macOS 아키텍처: $arch" ;; + esac + ;; + Linux) + case "$arch" in + x86_64|amd64) echo "opencodereview-linux-amd64" ;; + aarch64|arm64) echo "opencodereview-linux-arm64" ;; + *) error "지원하지 않는 Linux 아키텍처: $arch" ;; + esac + ;; + *) + error "지원하지 않는 OS입니다: $os. Windows인 경우 install-ocr.ps1을 사용하세요." + ;; + esac +} + +# ──────────────────────────────────────────── +# 최신 릴리즈 태그 가져오기 +# ──────────────────────────────────────────── +get_latest_tag() { + local json tag + info "GitHub API에서 Open Code Review 최신 릴리즈 정보를 가져오는 중..." + + if json=$(curl -fsSL --connect-timeout 10 "${API_URL}" 2>/dev/null); then + if command -v jq &>/dev/null; then + tag=$(echo "$json" | jq -r '.tag_name') + else + # jq가 없는 경우 grep & sed 사용 + tag=$(echo "$json" | grep '"tag_name":' | head -n 1 | sed -E 's/.*"tag_name": *"([^"]+)".*/\1/') + fi + fi + + if [[ -z "${tag:-}" || "${tag}" == "null" ]]; then + warn "최신 태그 정보를 가져오지 못했습니다. 기본 버전(${FALLBACK_VERSION})을 사용합니다." + echo "${FALLBACK_VERSION}" + else + echo "${tag}" + fi +} + +# ──────────────────────────────────────────── +# 메인 설치 함수 +# ──────────────────────────────────────────── +main() { + local asset_name tag url tmpdir dest_file + + asset_name="$(detect_platform)" + info "감지된 플랫폼 에셋: $asset_name" + + tag="$(get_latest_tag)" + info "적용할 버전 태그: $tag" + + url="https://github.com/${REPO}/releases/download/${tag}/${asset_name}" + + # 임시 디렉토리 생성 + tmpdir="$(mktemp -d)" + trap '[[ -d "${tmpdir:-}" ]] && rm -rf "$tmpdir"' EXIT + + dest_file="${tmpdir}/ocr" + + info "바이너리 다운로드 중: $url" + if ! curl -fsSL --progress-bar -o "$dest_file" "$url"; then + error "다운로드 실패: $url" + fi + + # 설치 디렉토리 확보 + mkdir -p "$INSTALL_DIR" + + local install_path="${INSTALL_DIR}/ocr" + info "설치 경로로 복사 중: ${install_path}" + cp "$dest_file" "$install_path" + chmod +x "$install_path" + + success "Open Code Review (ocr) 설치가 완료되었습니다!" + + # 버전 정보 출력 테스트 + if "$install_path" version &>/dev/null; then + info "버전 확인: $("$install_path" version)" + elif "$install_path" --version &>/dev/null; then + info "버전 확인: $("$install_path" --version)" + fi + + # PATH 환경 변수 체크 및 가이드 + if ! echo ":${PATH}:" | grep -q ":${INSTALL_DIR}:"; then + warn "'${INSTALL_DIR}' 경로가 PATH 환경 변수에 추가되어 있지 않습니다." + warn "다음 명령어를 통해 쉘 설정 파일(~/.bashrc 또는 ~/.zshrc)에 PATH를 추가하세요:" + warn " echo 'export PATH=\"\$HOME/.local/bin:\$PATH\"' >> ~/.zshrc && source ~/.zshrc" + fi +} + +main "$@"