docs(agent): add rules and skills
This commit is contained in:
46
.agent/rules/main.md
Normal file
46
.agent/rules/main.md
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
---
|
||||||
|
trigger: always_on
|
||||||
|
---
|
||||||
|
|
||||||
|
# Project Context: University Schedule System
|
||||||
|
|
||||||
|
## Project Overview
|
||||||
|
This project is a university scheduling system website.
|
||||||
|
- **Role**: Educational platform for managing schedules.
|
||||||
|
- **Language**: Mixed (Java Backend + Web Frontend).
|
||||||
|
- **Public URL**: https://magistr.zuev.company
|
||||||
|
|
||||||
|
## Directory Structure & Responsibilities
|
||||||
|
The project follows a specific folder structure. You must adhere to these paths:
|
||||||
|
|
||||||
|
- **`backend/`**: Contains the **Java** backend application source code.
|
||||||
|
- When working on API or server logic, focus here.
|
||||||
|
|
||||||
|
- **`frontend/`**: Contains the frontend source code. Note the strict role separation:
|
||||||
|
- `frontend/admin/`: Code specific to the **Administrator** interface.
|
||||||
|
- `frontend/teacher/`: Code specific to the **Teacher** interface.
|
||||||
|
- `frontend/student/`: Code specific to the **Student** interface.
|
||||||
|
- *Constraint*: Do not mix logic between these folders unless creating a shared utility.
|
||||||
|
|
||||||
|
- **`db/`**: Database configuration and data.
|
||||||
|
- `db/init/init.sql`: The SQL script responsible for **creating and initializing** the database schema (tables, initial data).
|
||||||
|
|
||||||
|
- **Root Files**:
|
||||||
|
- `compose.yaml`: The Docker Compose configuration. This file defines the services (backend, db, frontend servers) and how they run together.
|
||||||
|
- `.env`: Environment variables. Contains sensitive config (DB passwords, ports, API keys).
|
||||||
|
|
||||||
|
## External Dependencies (Parent Directory)
|
||||||
|
Some infrastructure components are located outside the project root:
|
||||||
|
|
||||||
|
- **`../caddy-proxy/`**: Located one level up relative to the project root.
|
||||||
|
- **Role**: Reverse proxy handling traffic for `magistr.zuev.company`.
|
||||||
|
- **`Caddyfile`**: Configuration for routing and SSL.
|
||||||
|
- **`compose.yaml`**: A separate Docker Compose file specifically for the proxy service.
|
||||||
|
|
||||||
|
## Workflow Guidelines
|
||||||
|
1. **Database Changes**: If you need to modify the database schema, you must update `db/init/init.sql` so the changes persist when the container is rebuilt.
|
||||||
|
2. **Configuration**: If adding new configuration parameters, add them to `.env` and reference them in `compose.yaml` or the application code.
|
||||||
|
3. **Routing/Proxy**: If there are issues with the domain or external access, check the configuration in `../caddy-proxy/Caddyfile`.
|
||||||
|
|
||||||
|
## Language Preference
|
||||||
|
- **Always answer in Russian**: This is a strict requirement from the user. All explanations, comments, and interactions must be in Russian unless specifically asked otherwise.
|
||||||
30
.agent/skills/git-commit-formatter/SKILL.md
Normal file
30
.agent/skills/git-commit-formatter/SKILL.md
Normal 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`
|
||||||
41
.agent/skills/git-push/SKILL.md
Normal file
41
.agent/skills/git-push/SKILL.md
Normal 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"`
|
||||||
31
.agent/skills/git-push/scripts/push_changes.sh
Executable file
31
.agent/skills/git-push/scripts/push_changes.sh
Executable 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
|
||||||
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
|
||||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,17 +1,16 @@
|
|||||||
# Игнорируем данные БД (но не init-скрипты)
|
# Игнорируем данные БД (но не init-скрипты)
|
||||||
db/data/
|
db/data/
|
||||||
postgres_data/
|
|
||||||
|
|
||||||
# Игнорируем секреты
|
# Игнорируем секреты
|
||||||
.env
|
.env
|
||||||
GEMINI.md
|
!GEMINI.md
|
||||||
AGENTS.md
|
!AGENTS.md
|
||||||
|
|
||||||
# Игнорируем системные папки IDE (если редактируете с ПК)
|
# Игнорируем системные папки IDE (если редактируете с ПК)
|
||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
.vscode/
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
.agent
|
!.agent
|
||||||
|
|
||||||
# Игнорируем временные файлы сборки (на будущее)
|
# Игнорируем временные файлы сборки (на будущее)
|
||||||
backend/target/
|
backend/target/
|
||||||
|
|||||||
Reference in New Issue
Block a user