docs(agent): add rules and skills
This commit is contained in:
23
.agent/skills/git-sync/SKILL.md
Normal file
23
.agent/skills/git-sync/SKILL.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Git Sync Skill
|
||||
|
||||
## Description
|
||||
This skill allows the agent to check the remote Git repository for updates. It automatically pulls changes if a new version is available on the remote server.
|
||||
|
||||
## Triggers
|
||||
Activate this skill when the user asks:
|
||||
- "Проверь обновления" (Check for updates)
|
||||
- "Загрузи новую версию" (Download new version)
|
||||
- "Синхронизируй с гитом" (Sync with git)
|
||||
- "Есть ли изменения?" (Are there changes?)
|
||||
|
||||
## Execution
|
||||
To run this skill, execute the bash script:
|
||||
|
||||
```bash
|
||||
/bin/bash .agent/skills/git-sync/scripts/check_and_pull.sh
|
||||
```
|
||||
|
||||
## Response Guidelines
|
||||
1. **Success**: If the script says "Successfully updated", inform the user the project is now on the latest version.
|
||||
2. **No Updates**: If the script says "Up-to-date", tell the user no changes were found.
|
||||
3. **Error**: If the script fails or reports conflicts, ask the user to check git status manually.
|
||||
43
.agent/skills/git-sync/scripts/check_and_pull.sh
Normal file
43
.agent/skills/git-sync/scripts/check_and_pull.sh
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
# --- НАСТРОЙКИ ---
|
||||
SERVER="root@192.168.1.87"
|
||||
REMOTE_PATH="/root/magistr/program"
|
||||
# -----------------
|
||||
|
||||
echo "📡 Connecting to remote server ($SERVER)..."
|
||||
|
||||
# 1. Запускаем fetch прямо на сервере
|
||||
# Флаг -o BatchMode=yes запрещает спрашивать пароль (чтобы скрипт не завис)
|
||||
ssh -o BatchMode=yes -o ConnectTimeout=10 "$SERVER" "cd $REMOTE_PATH && git fetch origin"
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "❌ Connection failed."
|
||||
echo "Make sure SSH keys are set up and the server is reachable."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 2. Проверяем количество новых коммитов (HEAD..@{u})
|
||||
BEHIND_COUNT=$(ssh "$SERVER" "cd $REMOTE_PATH && git rev-list --count HEAD..@{u} 2>/dev/null")
|
||||
|
||||
# Если переменная пустая — значит ошибка в гите
|
||||
if [ -z "$BEHIND_COUNT" ]; then
|
||||
echo "⚠️ Git status unknown. Upstream branch might not be set."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 3. Логика обновления
|
||||
if [ "$BEHIND_COUNT" -gt 0 ]; then
|
||||
echo "⬇️ Found $BEHIND_COUNT new commit(s). Pulling on server..."
|
||||
|
||||
# Выполняем git pull на сервере
|
||||
ssh "$SERVER" "cd $REMOTE_PATH && git pull"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✅ Server successfully updated!"
|
||||
else
|
||||
echo "❌ Update failed (merge conflicts?)."
|
||||
fi
|
||||
else
|
||||
echo "✨ Server is already up to date."
|
||||
fi
|
||||
Reference in New Issue
Block a user