Files
server-manager/CLAUDE.md
chrome-storm-c442 831fb66110 Update CLAUDE.md: primary goal, auto-bump docs, architecture
- Document primary purpose: Claude Code manages servers via /ssh skill by alias only
- Update versioning section: auto-bump in build.py, remove outdated release.py refs
- Add terminal features, session pool, keyboard layout independence
- Update project structure to reflect current architecture

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 04:37:20 -05:00

113 lines
5.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# CLAUDE.md — инструкции для Claude Code
## Основная цель проекта
ServerManager создан чтобы **Claude Code мог управлять серверами через глобальный скилл `/ssh`**, зная только алиасы серверов. Claude **никогда не видит логины и пароли** — скрипт `ssh.py` сам читает credentials из зашифрованного `servers.json`.
```
Claude Code → /ssh investor "uptime" → ssh.py → servers.json (encrypted) → SSH
↑ ↓
Видит только alias + команду Пароли остаются локально Результат
```
## Как пользоваться /ssh
```bash
# Выполнить команду на сервере
/ssh investor "uptime"
/ssh main-ovh "systemctl status nginx"
# Список серверов (без паролей)
/ssh --list
# Статус всех серверов
/ssh --status
# Загрузить файл
/ssh investor --upload /local/file /remote/path
# Скачать файл
/ssh investor --download /remote/file /local/path
# Проверить доступность
/ssh investor --ping
```
## Как настроить на новой машине
1. Клонировать: `git clone https://git.sensey24.ru/aibot777/server-manager.git`
2. `pip install -r requirements.txt`
3. `python main.py` → вкладка Setup → "Install Everything"
4. Добавить серверы через GUI → Claude Code сразу видит их через `/ssh --list`
Setup устанавливает:
- `ssh.py``~/.server-connections/`
- `encryption.py``~/.server-connections/`
- `/ssh` skill → `~/.claude/commands/ssh.md`
- SSH-ключ (ed25519)
## Версионирование
**Автоматическое.** `build.py` сам инкрементирует patch-версию при каждой сборке.
```bash
python build.py # автобамп 1.8.9 → 1.8.10, сборка
python build.py --no-bump # сборка без изменения версии
python build.py --clean # очистка артефактов + сборка
```
Файл версии: `version.py``__version__`
Semver: **MAJOR** (ломающие) | **MINOR** (новая фича) | **PATCH** (багфикс — автобамп)
Для minor/major бампа — вручную изменить version.py перед сборкой.
## Git — коммит и пуш
**ОБЯЗАТЕЛЬНО:** После завершения изменений — коммить и пуши:
```bash
git add <изменённые файлы>
git commit -m "vX.Y.Z: описание"
git push sensey master
```
- Remote: `sensey` (https://git.sensey24.ru/aibot777/server-manager.git)
- Ветка: `master`
## Архитектура
```
ServerManager/
├── main.py # Entry point
├── version.py # Version (auto-bumped by build.py)
├── build.py # PyInstaller + auto version bump
├── core/ # Business logic
│ ├── server_store.py # CRUD + encrypted JSON + backups
│ ├── encryption.py # Fernet encryption
│ ├── ssh_client.py # Paramiko SSH/SFTP/ShellSession
│ ├── session_pool.py # LRU session pool (max 5 concurrent)
│ ├── claude_setup.py # Claude Code integration installer
│ ├── status_checker.py # Background monitoring
│ ├── totp.py # TOTP/2FA (pyotp)
│ ├── i18n.py # EN/RU/ZH translations
│ └── logger.py # Rotating file logger
├── gui/ # CustomTkinter UI
│ ├── app.py # Main window
│ ├── sidebar.py # Server list + session indicators
│ ├── tabs/ # Terminal, Files, Info, Keys, 2FA, Setup
│ └── widgets/ # TerminalWidget (pyte), FileList, StatusBadge
├── tools/ # CLI tools (installed to ~/.server-connections/)
│ ├── ssh.py # SSH utility for Claude Code
│ └── skill-ssh.md # /ssh skill template
└── releases/ # Built executables
```
## Ключевые особенности терминала
- **pyte** эмулятор + tkinter Text виджет
- **Session pool** — сессии живут при переключении серверов, буфер сохраняется через pickle
- **Auto-sudo** — детекция `[sudo] password for` в выводе, автоматическая отправка пароля
- **Ctrl+C** — double-press (1.5s) для SIGINT, single = copy (если есть выделение)
- **Keyboard layout independent** — Ctrl+C/V/D/L/Z работают через keycode, не зависят от раскладки
- **Copy/Paste** — Ctrl+C/Ctrl+Shift+C/правый клик для копирования, Ctrl+V для вставки (с bracketed paste)