c589a216be
Made-with: Cursor
81 lines
2.1 KiB
Markdown
81 lines
2.1 KiB
Markdown
# Профили OpenClaude и direnv
|
||
|
||
Как хранить отдельные файлы окружения для локального / OpenAI / DeepSeek и подключать их при входе в каталог проекта.
|
||
|
||
## 1. Файлы профилей
|
||
|
||
Создайте каталог:
|
||
|
||
```bash
|
||
mkdir -p ~/.config/openclaude/profiles
|
||
```
|
||
|
||
`~/.config/openclaude/profiles/local.env`
|
||
|
||
```bash
|
||
export CLAUDE_CODE_USE_OPENAI=1
|
||
export OPENAI_BASE_URL=http://127.0.0.1:11434/v1
|
||
export OPENAI_MODEL=qwen2.5-coder:7b
|
||
unset OPENAI_API_KEY
|
||
```
|
||
|
||
`~/.config/openclaude/profiles/openai.env`
|
||
|
||
```bash
|
||
export CLAUDE_CODE_USE_OPENAI=1
|
||
export OPENAI_BASE_URL=https://api.openai.com/v1
|
||
export OPENAI_API_KEY=sk-REPLACE_ME
|
||
export OPENAI_MODEL=gpt-4o
|
||
```
|
||
|
||
`~/.config/openclaude/profiles/deepseek.env`
|
||
|
||
```bash
|
||
export CLAUDE_CODE_USE_OPENAI=1
|
||
export OPENAI_BASE_URL=https://api.deepseek.com/v1
|
||
export OPENAI_API_KEY=sk-REPLACE_ME
|
||
export OPENAI_MODEL=deepseek-chat
|
||
```
|
||
|
||
Права:
|
||
|
||
```bash
|
||
chmod 600 ~/.config/openclaude/profiles/*.env
|
||
```
|
||
|
||
## 2. Установка direnv (Linux)
|
||
|
||
```bash
|
||
sudo apt update
|
||
sudo apt install -y direnv
|
||
```
|
||
|
||
Для bash:
|
||
|
||
```bash
|
||
echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
|
||
source ~/.bashrc
|
||
```
|
||
|
||
Для zsh:
|
||
|
||
```bash
|
||
echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc
|
||
source ~/.zshrc
|
||
```
|
||
|
||
## 3. Автопрофиль на папку проекта
|
||
|
||
В корне проекта:
|
||
|
||
```bash
|
||
cat > .envrc <<'EOF'
|
||
source_env ~/.config/openclaude/profiles/local.env
|
||
EOF
|
||
direnv allow
|
||
```
|
||
|
||
На **Windows** нативный `direnv` используют реже; задайте переменные в текущей сессии PowerShell через `$env:ИМЯ="значение"`, добавьте их в профиль PowerShell, либо работайте в **WSL** и следуйте Linux-инструкциям выше.
|
||
|
||
В OpenClaude также можно пользоваться встроенной настройкой провайдеров (`/provider` в CLI) — см. документацию upstream [Gitlawb/openclaude](https://github.com/Gitlawb/openclaude).
|