📖 Guide
1️⃣ Install
- install
brew: https://brew.sh/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- install
pipx
brew install pipx
pipx ensurepath
- install
v-cr
方式一:安装 PyPI 远程仓库包
pipx install v-magic-code-review
方式二(推荐):安装本地项目包
# 进入你的项目根目录
cd /path/to/your/v-magic-code-review
# 使用可编辑模式(-e)安装
pipx install -e .
2️⃣ Setup environment variables
基础环境变量
设置以下环境变量,可直接写入到 ~/.zshrc 里:
# jira
export JIRA_HOST=https://jira.********.com
export JIRA_TOKEN=OTY**************************Y4
# confluence
export CONFLUENCE_HOST=https://wiki.********.com
export CONFLUENCE_TOKEN=MDQ2**************************1u
# gitlab
export GITLAB_HOST=https://gitlab.********.com
export GITLAB_TOKEN=_PH*****************UiW
如何获取这些变量:
| Variable | How to Get |
|---|---|
JIRA_TOKEN |
Go to Jira → 右上角头像点击 Profile → Personal Access Tokens → Create token |
CONFLUENCE_TOKEN |
Go to Confluence → 右上角头像点击 Settings → Personal Access Tokens → Create token |
GITLAB_TOKEN |
Go to GitLab → 左上角头像点击 Preferences → Access Tokens → Add new token |
Gemini Cookie
Gemini Cookie 可以手动配置,也可以自动获取,下面列出这两种方法
自动获取(推荐)
在浏览器中登陆 Gemini 后,使用命令就可以自动获取浏览器中的 Cookie,如果遇到权限提示,输入密码放行即可。
默认从 Chrome 浏览器获取 Cookie,如果你使用其他浏览器,请设置环境变量 BROWSER_NAME:
export BROWSER_NAME='arc'
支持的浏览器:
- chrome
- firefox
- brave
- edge
- safari
- arc
手动设置
设置以下环境变量,可直接写入到 ~/.zshrc 里:
# gemini(可不配置,不配置默认会从浏览器自动获取。建议不配置)
export GEMINI_COOKIE_SECURE_1PSID=g.a0KAaMS************************************************AROiSJgW0076
export GEMINI_COOKIE_SECURE_1PSIDTS=sidts-CjAB*****************************KZn7ScYuMQAA
如何获取这些变量:
| Variable | How to Get |
|---|---|
GEMINI_COOKIE_SECURE_1PSID(可忽略) |
Login to Gemini → F12 打开 Developer Tools → Application → Cookies → Copy value:__Secure-1PSID |
GEMINI_COOKIE_SECURE_1PSIDTS (可忽略) |
Login to Gemini → F12 打开 Developer Tools → Application → Cookies → Copy value:__Secure-1PSIDTS |
3️⃣ Usage
$ v-cr -h
usage: v-cr [-h] [-m MR_ID] [-o] [-c] [--prompt-templates PROMPT_TEMPLATES] [--list-prompt-templates] [--debug] [--version] [--advance] [JIRA_KEY OR MR_ID]
Magic Code Review
positional arguments:
JIRA_KEY OR MR_ID jira issue key or merge request id
options:
-h, --help show this help message and exit
-m, --mr-id MR_ID 【DEPRECATED】merge request id
-o, --only-code only review code diff
-c, --copy-prompt copy prompt to clipboard
--prompt-templates PROMPT_TEMPLATES
specific prompt template list, separated by [,]
--list-prompt-templates
list all prompt templates
--debug
--version
--advance use staged review
自动发送给 Gemini
Jira ID
$ v-cr ORI-100000
Merge Request ID
$ v-cr 30145
手动发送给 Gemini
$ v-cr ORI-100000 -c
......
......
2025-06-12 11:13:32,126 - INFO - ✨ issue comments length: 420
2025-06-12 11:13:33,231 - INFO - ✨ code diff length: 990
2025-06-12 11:13:33,387 - INFO - ✨ prompt length: 28737, tokens num: 13015
✅ Prompt 已复制到剪贴板
advance 模式
$ v-cr ORI-100000 --advance
这种模式适用于 Merge Request Changes 比较大的场景,工具会将 Changes 拆分后分组 Review,最后进行合并,给出审查报告。
注意:这种模式使用多次对话进行 Code Review,对 Gemini 的 Chat History 污染比较严重!
自定义 Prompt
创建
$ cd ~/.local/share/v-cr/prompts
$ touch my-prompt.txt
变量说明
| 变量 | 说明 |
|---|---|
{issue_summary} |
Jira Issue 标题 |
{issue_requirements} |
Jira Issue Description |
{issue_design} |
Jira Issue 关联的设计 Wiki |
{issue_comments} |
Jira Issue 的评论 |
{mr_description} |
Gitlab Merge Request 的描述 |
{mr_diff} |
Gitlab Merge Request 的代码变更 |
Prompt 示例
帮我优化一下代码变量命名
{mr_diff}
帮我看下需求和实现的代码是否一致,是否漏了需求
<section>需求</section>
{issue_requirements}
<section>代码实现 Diff</section>
{mr_diff}
列出可用的 Prompts
$ v-cr --list-prompt-template
Avalible Prompt Templates:
• DEFAULT
• my-prompt
指定 Prompt
$ v-cr ORI-100000 --prompt-template my-prompt
🤝 Contributing
- install
uv
brew install uv
- install virtualenv and dependencies
uv venv
uv sync --all-extras
Metadata
Release files for v-magic-code-review 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| v_magic_code_review-0.2.5.tar.gz | 35.7 kB | Without provenance | Details for v_magic_code_review-0.2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| v_magic_code_review-0.2.5-py3-none-any.whl | Python 3 | none | any | Details for v_magic_code_review-0.2.5-py3-none-any.whl |
Total release size: 77.0 kB
Release files / v_magic_code_review-0.2.5.tar.gz
| Download URL | v_magic_code_review-0.2.5.tar.gz |
|---|---|
| Size | 35.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
58fbc554558cc72b42bbc45ef256b7880615f8e6a44bef2dcd98b39776b84e73
|
|
BLAKE2b-256 checksum How to use checksums |
071473c458e1aa913bb0638df7fa7720752631c82092f68fc9f4ed0b591481ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Release files / v_magic_code_review-0.2.5-py3-none-any.whl
| Download URL | v_magic_code_review-0.2.5-py3-none-any.whl |
|---|---|
| Size | 41.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
47bbd8575f910e792a09429fb74d584e962037dfe073dde3a92af54810a9df59
|
|
BLAKE2b-256 checksum How to use checksums |
6c664ede24cd7bdcd96fc98f35271c2493a362ced6b7d0eb273e39fbba572c15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Security for v-magic-code-review 0.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.