284 lines
10 KiB
Markdown
Executable File
284 lines
10 KiB
Markdown
Executable File
# Gemini CLI — Patched
|
||
|
||
<!-- VERSION_BADGE:START -->
|
||
Patched Gemini CLI for use with custom API endpoints.
|
||
Latest: **v0.39.1** (13 patches).
|
||
<!-- VERSION_BADGE:END -->
|
||
|
||
> Node.js v20+ required. One-liner installer подтянет Node.js если его нет.
|
||
|
||
## Install
|
||
|
||
### One-liner — все платформы
|
||
|
||
**Linux (Debian/Ubuntu/RHEL/Fedora):**
|
||
```bash
|
||
curl -fsSL -H "Authorization: token cadffcb0a6a3be728ac1ff619bb40c86588f6837" \
|
||
https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/gemini/ugemini_install.sh \
|
||
-o /tmp/ugemini_install.sh && sudo bash /tmp/ugemini_install.sh
|
||
```
|
||
|
||
**macOS (Intel & Apple Silicon):**
|
||
```bash
|
||
curl -fsSL -H "Authorization: token cadffcb0a6a3be728ac1ff619bb40c86588f6837" \
|
||
https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/gemini/ugemini_install.sh \
|
||
-o /tmp/ugemini_install.sh && sudo bash /tmp/ugemini_install.sh
|
||
```
|
||
|
||
> macOS: env vars (`GEMINI_API_KEY`, `GOOGLE_GEMINI_BASE_URL`) добавляются в `~/.zshrc`.
|
||
> Если sudo попросит — введите пароль.
|
||
|
||
**Windows (PowerShell as Administrator):**
|
||
```powershell
|
||
$h=@{Authorization="token cadffcb0a6a3be728ac1ff619bb40c86588f6837"}
|
||
Set-ExecutionPolicy Bypass -Scope Process -Force
|
||
iwr "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/gemini/ugemini_install.ps1" -OutFile "$env:TEMP\ugemini_install.ps1" -Headers $h
|
||
. "$env:TEMP\ugemini_install.ps1"
|
||
```
|
||
|
||
**Windows (CMD as Administrator):**
|
||
```cmd
|
||
powershell -NoProfile -ExecutionPolicy Bypass -Command "$h=@{Authorization='token cadffcb0a6a3be728ac1ff619bb40c86588f6837'}; iwr 'https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/gemini/ugemini_install.ps1' -OutFile \"$env:TEMP\ugemini_install.ps1\" -Headers $h; & \"$env:TEMP\ugemini_install.ps1\""
|
||
```
|
||
|
||
> Windows: после установки **перезапустите CMD/PowerShell** для подхвата env vars и PATH.
|
||
|
||
Установщик выполнит:
|
||
1. Проверит prerequisites (Node.js >= 20, Python3)
|
||
2. Установит `@google/gemini-cli` если нет
|
||
3. Скачает и применит 13 патчей
|
||
4. Настроит auth и env vars
|
||
5. Проверит тестовым промптом
|
||
|
||
### Two-command npm install (manual)
|
||
|
||
Если установщик не подходит — можно вручную через npm registry:
|
||
|
||
**Linux / macOS:**
|
||
```bash
|
||
npm config set @google:registry https://npm.sensey24.ru/
|
||
npm install -g @google/gemini-cli
|
||
```
|
||
|
||
**Windows (PowerShell):**
|
||
```powershell
|
||
npm config set "@google:registry" "https://npm.sensey24.ru/"
|
||
npm install -g @google/gemini-cli
|
||
```
|
||
|
||
**Windows (CMD):**
|
||
```cmd
|
||
npm config set "@google:registry" "https://npm.sensey24.ru/"
|
||
npm install -g @google/gemini-cli
|
||
```
|
||
|
||
После npm-установки нужно вручную настроить auth и env vars (см. ниже).
|
||
|
||
### Manual configure (если устанавливали через npm)
|
||
|
||
npm-пакет содержит все 13 патчей (proxy URLs, model defaults, UI, compression).
|
||
Нужно лишь настроить auth и env vars.
|
||
|
||
**Linux / macOS:**
|
||
```bash
|
||
echo 'export GEMINI_API_KEY="YOUR_API_KEY"' >> ~/.bashrc
|
||
echo 'export GOOGLE_GEMINI_BASE_URL="https://ai.37-187-136-86.sslip.io"' >> ~/.bashrc
|
||
source ~/.bashrc
|
||
|
||
mkdir -p ~/.gemini
|
||
cat > ~/.gemini/settings.json << 'EOF'
|
||
{
|
||
"security": {
|
||
"auth": { "selectedType": "gemini-api-key" },
|
||
"folderTrust": { "enabled": false }
|
||
},
|
||
"telemetry": { "enabled": false, "logPrompts": false },
|
||
"general": { "defaultApprovalMode": "yolo" }
|
||
}
|
||
EOF
|
||
```
|
||
|
||
**macOS (zsh — default):**
|
||
```bash
|
||
echo 'export GEMINI_API_KEY="YOUR_API_KEY"' >> ~/.zshrc
|
||
echo 'export GOOGLE_GEMINI_BASE_URL="https://ai.37-187-136-86.sslip.io"' >> ~/.zshrc
|
||
source ~/.zshrc
|
||
```
|
||
|
||
**Windows (PowerShell):**
|
||
```powershell
|
||
[System.Environment]::SetEnvironmentVariable("GEMINI_API_KEY", "YOUR_API_KEY", "User")
|
||
[System.Environment]::SetEnvironmentVariable("GOOGLE_GEMINI_BASE_URL", "https://ai.37-187-136-86.sslip.io", "User")
|
||
$env:GEMINI_API_KEY = "YOUR_API_KEY"
|
||
$env:GOOGLE_GEMINI_BASE_URL = "https://ai.37-187-136-86.sslip.io"
|
||
$d = "$env:USERPROFILE\.gemini"; New-Item -ItemType Directory -Force -Path $d | Out-Null
|
||
[System.IO.File]::WriteAllText("$d\settings.json", '{"security":{"auth":{"selectedType":"gemini-api-key"},"folderTrust":{"enabled":false}},"telemetry":{"enabled":false,"logPrompts":false},"general":{"defaultApprovalMode":"yolo"}}')
|
||
```
|
||
|
||
**Windows (CMD):**
|
||
```cmd
|
||
setx GEMINI_API_KEY "YOUR_API_KEY"
|
||
setx GOOGLE_GEMINI_BASE_URL "https://ai.37-187-136-86.sslip.io"
|
||
mkdir "%USERPROFILE%\.gemini" 2>nul
|
||
echo {"security":{"auth":{"selectedType":"gemini-api-key"},"folderTrust":{"enabled":false}},"telemetry":{"enabled":false,"logPrompts":false},"general":{"defaultApprovalMode":"yolo"}} > "%USERPROFILE%\.gemini\settings.json"
|
||
```
|
||
|
||
### Verify
|
||
|
||
```bash
|
||
gemini -p "Hello"
|
||
```
|
||
|
||
## Update
|
||
|
||
### One-liner
|
||
|
||
**Linux / macOS:**
|
||
```bash
|
||
curl -fsSL -H "Authorization: token cadffcb0a6a3be728ac1ff619bb40c86588f6837" \
|
||
https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/gemini/ugemini_update.sh \
|
||
-o /tmp/ugemini_update.sh && sudo bash /tmp/ugemini_update.sh
|
||
```
|
||
|
||
**Windows (PowerShell as Administrator):**
|
||
```powershell
|
||
$h=@{Authorization="token cadffcb0a6a3be728ac1ff619bb40c86588f6837"}
|
||
Set-ExecutionPolicy Bypass -Scope Process -Force
|
||
iwr "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/gemini/ugemini_update.ps1" -OutFile "$env:TEMP\ugemini_update.ps1" -Headers $h
|
||
. "$env:TEMP\ugemini_update.ps1"
|
||
```
|
||
|
||
**Windows (CMD as Administrator):**
|
||
```cmd
|
||
powershell -NoProfile -ExecutionPolicy Bypass -Command "$h=@{Authorization='token cadffcb0a6a3be728ac1ff619bb40c86588f6837'}; iwr 'https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/gemini/ugemini_update.ps1' -OutFile \"$env:TEMP\ugemini_update.ps1\" -Headers $h; & \"$env:TEMP\ugemini_update.ps1\""
|
||
```
|
||
|
||
### Manual update via npm
|
||
|
||
```bash
|
||
npm install -g @google/gemini-cli
|
||
```
|
||
|
||
Settings и env vars сохраняются между обновлениями.
|
||
|
||
## Uninstall
|
||
|
||
**Linux / macOS:**
|
||
```bash
|
||
curl -fsSL -H "Authorization: token cadffcb0a6a3be728ac1ff619bb40c86588f6837" \
|
||
https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/gemini/ugemini_uninstall.sh \
|
||
-o /tmp/ugemini_uninstall.sh && sudo bash /tmp/ugemini_uninstall.sh
|
||
```
|
||
|
||
**Windows (PowerShell as Administrator):**
|
||
```powershell
|
||
$h=@{Authorization="token cadffcb0a6a3be728ac1ff619bb40c86588f6837"}
|
||
Set-ExecutionPolicy Bypass -Scope Process -Force
|
||
iwr "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/gemini/ugemini_uninstall.ps1" -OutFile "$env:TEMP\ugemini_uninstall.ps1" -Headers $h
|
||
. "$env:TEMP\ugemini_uninstall.ps1"
|
||
```
|
||
|
||
Удаляются: npm-пакет, `~/.gemini/`, env vars, npm registry config.
|
||
|
||
## What's included in the npm package vs what needs manual setup
|
||
|
||
| Patch | What | Included in npm? |
|
||
|-------|------|:-:|
|
||
| 1-3 | Proxy URLs (API + Vertex) | Yes |
|
||
| 4-5 | Sandbox fixes (env vars + whitelist) | Yes |
|
||
| 6 | Auth settings (~/.gemini/settings.json) | **No — manual** |
|
||
| 7-8 | Auto-update registry + commands | Yes |
|
||
| 9 | Auto-permissions (YOLO mode) | Yes |
|
||
| 10 | Default model constants (3.x) | Yes |
|
||
| 11-13 | UI descriptions + compression aliases | Yes |
|
||
|
||
## What Gets Patched
|
||
|
||
| # | Target | What |
|
||
|---|--------|------|
|
||
| 1 | `gemini_base_url` | Route API through proxy |
|
||
| 2 | `vertex_base_url_regional` | Route Vertex AI (regional) through proxy |
|
||
| 3 | `vertex_base_url_global` | Route Vertex AI (global) through proxy |
|
||
| 4 | `sanitize_env_url` | Allow URLs in .env files |
|
||
| 5 | `auth_env_whitelist` | Allow proxy URL in sandbox |
|
||
| 6 | `user_settings` | Set API key auth, disable telemetry |
|
||
| 7 | `auto_update_registry` | Redirect npm registry to proxy |
|
||
| 8 | `auto_update_commands` | Add --registry to update commands |
|
||
| 9 | `auto_permissions` | Allow YOLO mode from settings |
|
||
| 10 | `default_models` | Override default model constants to 3.x |
|
||
| 11 | `model_dialog_desc` | Fix model names in UI picker |
|
||
| 12 | `compression_aliases` | Fix compression config aliases |
|
||
| 13 | `agent_config_desc` | Fix example model in agent config |
|
||
|
||
## Available Models
|
||
|
||
- `gemini-3.1-pro-preview` — Main production model (default)
|
||
- `gemini-3.1-pro-high` — High quality variant
|
||
- `gemini-3.1-pro-low` — Fast variant
|
||
- `gemini-3-pro-preview` — Gemini 3.0 Pro
|
||
- `gemini-3-flash-preview` — Fast model
|
||
- `gemini-2.5-pro` — Legacy (still available)
|
||
- `gemini-2.5-flash` — Legacy fast
|
||
|
||
## Troubleshooting
|
||
|
||
### "GEMINI_API_KEY not set"
|
||
|
||
**Linux / macOS:**
|
||
```bash
|
||
export GEMINI_API_KEY="YOUR_API_KEY"
|
||
export GOOGLE_GEMINI_BASE_URL="https://ai.37-187-136-86.sslip.io"
|
||
```
|
||
|
||
**Windows (PowerShell):**
|
||
```powershell
|
||
[System.Environment]::SetEnvironmentVariable("GEMINI_API_KEY", "YOUR_API_KEY", "User")
|
||
[System.Environment]::SetEnvironmentVariable("GOOGLE_GEMINI_BASE_URL", "https://ai.37-187-136-86.sslip.io", "User")
|
||
# Перезапустите PowerShell
|
||
```
|
||
|
||
**Windows (CMD):**
|
||
```cmd
|
||
setx GEMINI_API_KEY "YOUR_API_KEY"
|
||
setx GOOGLE_GEMINI_BASE_URL "https://ai.37-187-136-86.sslip.io"
|
||
```
|
||
|
||
### "IneligibleTierError"
|
||
|
||
Settings ещё используют OAuth. Перезапустите патчер:
|
||
```bash
|
||
python3 gemini_patcher.py --settings-only
|
||
```
|
||
|
||
### Windows: "gemini is not recognized"
|
||
|
||
Перезапустите CMD/PowerShell. Либо вручную обновите PATH в текущей сессии:
|
||
```powershell
|
||
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
|
||
```
|
||
|
||
### Deprecated settings spam
|
||
|
||
Если видите повторяющиеся warnings:
|
||
```
|
||
The system configuration contains deprecated settings: [experimental.codebaseInvestigatorSettings]
|
||
```
|
||
ключ есть в **system-level** конфигах. Удалите его — см. секцию Troubleshooting в [главном README](../README.md#gemini-cli-deprecated-settings-spam).
|
||
|
||
### Rollback
|
||
|
||
```bash
|
||
sudo python3 gemini_patcher.py --rollback
|
||
```
|
||
|
||
## Files
|
||
|
||
| File | Purpose |
|
||
|------|---------|
|
||
| `gemini_patcher.py` | Main patcher — detects Gemini CLI, applies 13 patches |
|
||
| `gemini_config.json` | Config — proxy URL, API key, models |
|
||
| `ugemini_install.sh` / `.ps1` | One-liner installer (Linux/macOS / Windows) |
|
||
| `ugemini_update.sh` / `.ps1` | Update script (Linux/macOS / Windows) |
|
||
| `ugemini_uninstall.sh` / `.ps1` | Uninstaller (Linux/macOS / Windows) |
|
||
| `releases/index.json` | Version index |
|