docs(agent): add rules and skills

This commit is contained in:
EgorZuev
2026-02-18 21:56:57 +00:00
parent bcabb560a4
commit 64d85eab55
7 changed files with 217 additions and 4 deletions

View File

@@ -0,0 +1,30 @@
---
name: git-commit-formatter
description: Formats git commit messages according to Conventional Commits specification. Use this when the user asks to commit changes or write a commit message.
---
# Git Commit Formatter Skill
When writing a git commit message, you MUST follow the Conventional Commits specification.
## Format
`<type>[optional scope]: <description>`
## Allowed Types
- **feat**: A new feature
- **fix**: A bug fix
- **docs**: Documentation only changes
- **style**: Changes that do not affect the meaning of the code (white-space, formatting, etc)
- **refactor**: A code change that neither fixes a bug nor adds a feature
- **perf**: A code change that improves performance
- **test**: Adding missing tests or correcting existing tests
- **chore**: Changes to the build process or auxiliary tools and libraries such as documentation generation
## Instructions
1. Analyze the changes to determine the primary `type`.
2. Identify the `scope` if applicable (e.g., specific component or file).
3. Write a concise `description` in imperative mood (e.g., "add feature" not "added feature").
4. If there are breaking changes, add a footer starting with `BREAKING CHANGE:`.
## Example
`feat(auth): implement login with google`

View File

@@ -0,0 +1,41 @@
# Git Push & Format Skill
## Description
Formats git commit messages according to Conventional Commits specification and pushes changes to the remote repository. Use this when the user asks to commit changes, save progress, or upload code.
## Triggers
- "Запушь изменения" (Push changes)
- "Сделай коммит" (Make a commit)
- "Сохрани в гит" (Save to git)
- "Сделай пуш" (Make a push)
- "Запушь" (Push)
## Format (Conventional Commits)
When writing a git commit message, you MUST follow this format:
`<type>[optional scope]: <description>`
### Allowed Types
- **feat**: A new feature
- **fix**: A bug fix
- **docs**: Documentation only changes
- **style**: Changes that do not affect the meaning of the code (white-space, formatting, etc)
- **refactor**: A code change that neither fixes a bug nor adds a feature
- **perf**: A code change that improves performance
- **test**: Adding missing tests or correcting existing tests
- **chore**: Changes to the build process or auxiliary tools and libraries
### Instructions for Agent
1. Analyze the user's request or recent file changes to determine the `type` and `description`.
2. Construct the commit message string (e.g., "fix(auth): correct token validation").
3. **Execute** the bash script below, passing the generated message as an argument.
## Execution
Run the following command (replace .YOUR_MESSAGE. with the formatted string):
```bash
/bin/bash .agent/skills/git-push/scripts/push_changes.sh "YOUR_MESSAGE"
```
## Example Usage
If user says "I fixed the login bug", you execute:
`/bin/bash .agent/skills/git-push/scripts/push_changes.sh "fix(auth): resolve login error"`

View File

@@ -0,0 +1,31 @@
#!/bin/bash
# --- НАСТРОЙКИ (Проверь, чтобы совпадали с check_and_pull.sh) ---
SERVER="root@192.168.1.87"
REMOTE_PATH="/root/magistr/program"
# -------------------------------------------------------------
COMMIT_MSG="$1"
# Проверка: если сообщение пустое, ругаемся
if [ -z "$COMMIT_MSG" ]; then
echo "❌ Error: Commit message is required."
echo "Usage: ./push_changes.sh \"feat: description\""
exit 1
fi
echo "🚀 Starting Push Sequence to $SERVER..."
# Выполняем цепочку команд на сервере одной строкой
ssh -o BatchMode=yes "$SERVER" "export LANG=C.UTF-8 && cd $REMOTE_PATH && \
git add . && \
git commit -m \"$COMMIT_MSG\" && \
git push origin main"
# Проверяем код возврата последней команды
if [ $? -eq 0 ]; then
echo "✅ Success! Changes pushed to remote."
else
echo "❌ Failed to push. Check the output above for errors."
exit 1
fi

View 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.

View 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