Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions OmniCore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch to a more portable shebang (e.g., #!/usr/bin/env bash) to ensure the script works across different environments.

Suggested change
#!/bin/bash
#!/usr/bin/env bash

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding set -euo pipefail after the shebang to ensure the script exits on errors, treats unset variables as failures, and fails in pipelines.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding set -euo pipefail after the shebang to enable strict error handling and avoid silent failures.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI May 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add set -euo pipefail after the shebang to enable fail-fast behavior and catch errors in piped commands.

Copilot uses AI. Check for mistakes.

Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding set -euo pipefail after the shebang to fail fast on errors, undefined variables, or pipe failures.

Copilot uses AI. Check for mistakes.
echo "🔹 [1] Установка зависимостей для Python..."
if [ -f "requirements.txt" ]; then
pip install -r requirements.txt || pip3 install -r requirements.txt
else
echo "⚠️ Файл requirements.txt не найден. Создаю..."
echo -e "requests\nwebsocket-client" > requirements.txt
Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using echo -e is not portable across all shells. Consider using printf '%s ' "requests" "websocket-client" > requirements.txt for consistent behavior.

Suggested change
echo -e "requests\nwebsocket-client" > requirements.txt
printf '%s\n' "requests" "websocket-client" > requirements.txt

Copilot uses AI. Check for mistakes.
pip install -r requirements.txt || pip3 install -r requirements.txt
Comment on lines +5 to +9
Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] To avoid ambiguity, explicitly call pip3 first for Python 3 environments and fall back to pip only if needed.

Suggested change
pip install -r requirements.txt || pip3 install -r requirements.txt
else
echo "⚠️ Файл requirements.txt не найден. Создаю..."
echo -e "requests\nwebsocket-client" > requirements.txt
pip install -r requirements.txt || pip3 install -r requirements.txt
pip3 install -r requirements.txt || pip install -r requirements.txt
else
echo "⚠️ Файл requirements.txt не найден. Создаю..."
echo -e "requests\nwebsocket-client" > requirements.txt
pip3 install -r requirements.txt || pip install -r requirements.txt

Copilot uses AI. Check for mistakes.
Comment on lines +4 to +9
Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Falling back to pip3 after pip may mask which interpreter is being used. It might be clearer to detect the Python version first or consistently use one installer.

Suggested change
if [ -f "requirements.txt" ]; then
pip install -r requirements.txt || pip3 install -r requirements.txt
else
echo "⚠️ Файл requirements.txt не найден. Создаю..."
echo -e "requests\nwebsocket-client" > requirements.txt
pip install -r requirements.txt || pip3 install -r requirements.txt
# Detect Python version and set the appropriate pip command
if command -v python3 &>/dev/null; then
PYTHON_CMD="python3"
PIP_CMD="pip3"
elif command -v python &>/dev/null; then
PYTHON_CMD="python"
PIP_CMD="pip"
else
echo "❌ Python не установлен. Установите Python и повторите попытку."
exit 1
fi
if [ -f "requirements.txt" ]; then
$PIP_CMD install -r requirements.txt
else
echo "⚠️ Файл requirements.txt не найден. Создаю..."
echo -e "requests\nwebsocket-client" > requirements.txt
$PIP_CMD install -r requirements.txt

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +9
Copy link

Copilot AI May 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider exiting the script if neither pip nor pip3 succeeds to avoid continuing with missing dependencies.

Suggested change
pip install -r requirements.txt || pip3 install -r requirements.txt
else
echo "⚠️ Файл requirements.txt не найден. Создаю..."
echo -e "requests\nwebsocket-client" > requirements.txt
pip install -r requirements.txt || pip3 install -r requirements.txt
pip install -r requirements.txt || pip3 install -r requirements.txt || { echo "❌ Ошибка: Не удалось установить зависимости. Убедитесь, что pip или pip3 установлены и настроены."; exit 1; }
else
echo "⚠️ Файл requirements.txt не найден. Создаю..."
echo -e "requests\nwebsocket-client" > requirements.txt
pip install -r requirements.txt || pip3 install -r requirements.txt || { echo "❌ Ошибка: Не удалось установить зависимости. Убедитесь, что pip или pip3 установлены и настроены."; exit 1; }

Copilot uses AI. Check for mistakes.
fi

echo "🔸 [2] Установка зависимостей для Node.js..."
if [ -f "package.json" ]; then
npm install
else
echo "⚠️ Файл package.json не найден. Проверь наличие Node.js зависимостей."
fi

echo "🌀 [3] Запуск TreeOM AppServer..."
python3 TreeOM_AppServer.py &

echo "🌐 [4] Запуск WebSocket-сервера..."
node websocket_server.js &

echo "💎 [5] Запуск Discord-интеграции..."
node discord_bot.js &

echo "🧠 [6] Запуск Live Web-интерфейса..."
npx live-server --port=8080 &
Copy link

Copilot AI May 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Extract the hardcoded port 8080 into a variable or parameter to make the script more configurable.

Suggested change
npx live-server --port=8080 &
npx live-server --port=$LIVE_SERVER_PORT &

Copilot uses AI. Check for mistakes.

sleep 2
Copy link

Copilot AI May 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a fixed sleep introduces potential race conditions; consider polling the service or checking the port readiness instead of a static delay.

Copilot uses AI. Check for mistakes.
echo "🛠️ [7] Запуск мониторинга структуры..."
python3 treeom_monitor.py &
Comment on lines +20 to +33
Copy link

Copilot AI May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider capturing the process ID of this background process to facilitate error handling and proper cleanup later.

Suggested change
python3 TreeOM_AppServer.py &
echo "🌐 [4] Запуск WebSocket-сервера..."
node websocket_server.js &
echo "💎 [5] Запуск Discord-интеграции..."
node discord_bot.js &
echo "🧠 [6] Запуск Live Web-интерфейса..."
npx live-server --port=8080 &
sleep 2
echo "🛠️ [7] Запуск мониторинга структуры..."
python3 treeom_monitor.py &
python3 TreeOM_AppServer.py & TREEOM_PID=$!
echo "🌐 [4] Запуск WebSocket-сервера..."
node websocket_server.js & WEBSOCKET_PID=$!
echo "💎 [5] Запуск Discord-интеграции..."
node discord_bot.js & DISCORD_PID=$!
echo "🧠 [6] Запуск Live Web-интерфейса..."
npx live-server --port=8080 & LIVE_SERVER_PID=$!
sleep 2
echo "🛠️ [7] Запуск мониторинга структуры..."
python3 treeom_monitor.py & MONITOR_PID=$!

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +33
Copy link

Copilot AI May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple background processes are launched without any error handling or status monitoring. Consider adding checks or a monitoring mechanism to ensure these processes start successfully.

Suggested change
python3 TreeOM_AppServer.py &
echo "🌐 [4] Запуск WebSocket-сервера..."
node websocket_server.js &
echo "💎 [5] Запуск Discord-интеграции..."
node discord_bot.js &
echo "🧠 [6] Запуск Live Web-интерфейса..."
npx live-server --port=8080 &
sleep 2
echo "🛠️ [7] Запуск мониторинга структуры..."
python3 treeom_monitor.py &
python3 TreeOM_AppServer.py &
APP_SERVER_PID=$!
if ! kill -0 $APP_SERVER_PID 2>/dev/null; then
echo "❌ Ошибка: TreeOM AppServer не удалось запустить."
exit 1
fi
echo "🌐 [4] Запуск WebSocket-сервера..."
node websocket_server.js &
WEBSOCKET_SERVER_PID=$!
if ! kill -0 $WEBSOCKET_SERVER_PID 2>/dev/null; then
echo "❌ Ошибка: WebSocket-сервер не удалось запустить."
exit 1
fi
echo "💎 [5] Запуск Discord-интеграции..."
node discord_bot.js &
DISCORD_BOT_PID=$!
if ! kill -0 $DISCORD_BOT_PID 2>/dev/null; then
echo "❌ Ошибка: Discord-интеграцию не удалось запустить."
exit 1
fi
echo "🧠 [6] Запуск Live Web-интерфейса..."
npx live-server --port=8080 &
LIVE_SERVER_PID=$!
if ! kill -0 $LIVE_SERVER_PID 2>/dev/null; then
echo "❌ Ошибка: Live Web-интерфейс не удалось запустить."
exit 1
fi
sleep 2
echo "🛠️ [7] Запуск мониторинга структуры..."
python3 treeom_monitor.py &
MONITOR_PID=$!
if ! kill -0 $MONITOR_PID 2>/dev/null; then
echo "❌ Ошибка: Мониторинг структуры не удалось запустить."
exit 1
fi

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +33
Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Multiple background processes are started without tracking or cleanup. Consider capturing PIDs and using a trap to ensure processes are terminated cleanly on script exit.

Suggested change
python3 TreeOM_AppServer.py &
echo "🌐 [4] Запуск WebSocket-сервера..."
node websocket_server.js &
echo "💎 [5] Запуск Discord-интеграции..."
node discord_bot.js &
echo "🧠 [6] Запуск Live Web-интерфейса..."
npx live-server --port=8080 &
sleep 2
echo "🛠️ [7] Запуск мониторинга структуры..."
python3 treeom_monitor.py &
python3 TreeOM_AppServer.py & PIDS="$PIDS $!"
echo "🌐 [4] Запуск WebSocket-сервера..."
node websocket_server.js & PIDS="$PIDS $!"
echo "💎 [5] Запуск Discord-интеграции..."
node discord_bot.js & PIDS="$PIDS $!"
echo "🧠 [6] Запуск Live Web-интерфейса..."
npx live-server --port=8080 & PIDS="$PIDS $!"
sleep 2
echo "🛠️ [7] Запуск мониторинга структуры..."
python3 treeom_monitor.py & PIDS="$PIDS $!"

Copilot uses AI. Check for mistakes.

sleep 2
Comment on lines +31 to +35
Copy link

Copilot AI May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a fixed sleep duration to wait for background processes to start may lead to unpredictable behavior. Consider using a polling mechanism or checking for service readiness instead of a fixed delay.

Suggested change
sleep 2
echo "🛠️ [7] Запуск мониторинга структуры..."
python3 treeom_monitor.py &
sleep 2
echo "⏳ Ожидание запуска TreeOM AppServer..."
for i in {1..10}; do
if pgrep -f "TreeOM_AppServer.py" > /dev/null; then
echo "✔️ TreeOM AppServer запущен."
break
fi
sleep 1
done
echo "🛠️ [7] Запуск мониторинга структуры..."
python3 treeom_monitor.py &
echo "⏳ Ожидание запуска WebSocket-сервера..."
for i in {1..10}; do
if pgrep -f "websocket_server.js" > /dev/null; then
echo "✔️ WebSocket-сервер запущен."
break
fi
sleep 1
done

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +35
Copy link

Copilot AI May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using fixed sleep durations to wait for background processes may be brittle. Consider implementing a loop to check for process readiness or using 'wait' to ensure proper synchronization.

Suggested change
sleep 2
echo "🛠️ [7] Запуск мониторинга структуры..."
python3 treeom_monitor.py &
sleep 2
echo "⏳ Ожидание запуска TreeOM AppServer..."
timeout 10 bash -c 'until pgrep -f "TreeOM_AppServer.py" > /dev/null; do sleep 1; done' || { echo "❌ TreeOM AppServer не запустился!"; exit 1; }
echo "🛠️ [7] Запуск мониторинга структуры..."
python3 treeom_monitor.py &
echo "⏳ Ожидание запуска treeom_monitor.py..."
timeout 10 bash -c 'until pgrep -f "treeom_monitor.py" > /dev/null; do sleep 1; done' || { echo "❌ treeom_monitor.py не запустился!"; exit 1; }

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +35
Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using fixed sleeps can lead to race conditions; consider checking service health or logs instead of a fixed delay.

Suggested change
sleep 2
echo "🛠️ [7] Запуск мониторинга структуры..."
python3 treeom_monitor.py &
sleep 2
echo "⏳ Ожидание запуска TreeOM AppServer..."
while ! netstat -tuln | grep -q ':5000'; do
sleep 0.5
done
echo "🛠️ [7] Запуск мониторинга структуры..."
python3 treeom_monitor.py &
echo "⏳ Ожидание запуска TreeOM Monitor..."
while ! pgrep -f treeom_monitor.py > /dev/null; do
sleep 0.5
done

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This second fixed delay duplicates the earlier one; consider consolidating waits or replacing with readiness checks.

Suggested change
sleep 2
while ! pgrep -f "treeom_monitor.py" > /dev/null; do
sleep 1
done

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +35
Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using fixed sleep intervals to wait for background processes may be unreliable. Consider using process checks or the 'wait' command to ensure background tasks are properly started before proceeding.

Suggested change
sleep 2
echo "🛠️ [7] Запуск мониторинга структуры..."
python3 treeom_monitor.py &
sleep 2
while ! nc -z localhost 8080; do
sleep 1
done
echo "🛠️ [7] Запуск мониторинга структуры..."
python3 treeom_monitor.py &
while ! pgrep -f "treeom_monitor.py" > /dev/null; do
sleep 1
done

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI May 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace the static delay with an active readiness check (e.g., nc or curl) to confirm the monitor process is accepting connections.

Suggested change
sleep 2
echo "⏳ Ожидание готовности treeom_monitor.py..."
for i in {1..10}; do
if nc -z localhost 5000; then
echo "✔️ treeom_monitor.py готов."
break
fi
sleep 1
done
if ! nc -z localhost 5000; then
echo "❌ Ошибка: treeom_monitor.py не готов после 10 секунд ожидания."
exit 1
fi

Copilot uses AI. Check for mistakes.
echo "📦 [8] Проверка CI/CD pipeline..."
if [ -f .github/workflows/main.yml ]; then
echo "✔️ GitHub Actions workflow найден."
else
echo "⚠️ Workflow не найден! Создаю шаблон..."
mkdir -p .github/workflows
cp ./templates/ci_template.yml .github/workflows/main.yml
Copy link

Copilot AI May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script attempts to copy a CI template without verifying that './templates/ci_template.yml' exists. Consider adding a check to ensure the template file is present before copying.

Suggested change
cp ./templates/ci_template.yml .github/workflows/main.yml
if [ -f "./templates/ci_template.yml" ]; then
cp ./templates/ci_template.yml .github/workflows/main.yml
else
echo "❌ Шаблон CI/CD pipeline (./templates/ci_template.yml) не найден. Проверьте наличие файла."
fi

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI May 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verify the existence of templates/ci_template.yml before copying to prevent errors when the source file is missing.

Suggested change
cp ./templates/ci_template.yml .github/workflows/main.yml
if [ -f "./templates/ci_template.yml" ]; then
cp ./templates/ci_template.yml .github/workflows/main.yml
else
echo "❌ Шаблон CI/CD pipeline (ci_template.yml) не найден. Проверьте наличие файла в папке templates."
fi

Copilot uses AI. Check for mistakes.
fi

echo "📘 [9] Обновление README.md..."
Copy link

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If README.md does not exist, grep will fail; you may want to ensure the file exists or create it before grepping.

Suggested change
echo "📘 [9] Обновление README.md..."
echo "📘 [9] Обновление README.md..."
if [ ! -f "README.md" ]; then
echo "⚠️ Файл README.md не найден. Создаю пустой файл..."
touch README.md
fi

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running grep on README.md will error out if the file doesn't exist. Add a check to create README.md first or guard the grep with a file-existence test.

Suggested change
echo "📘 [9] Обновление README.md..."
echo "📘 [9] Обновление README.md..."
if [ ! -f "README.md" ]; then
echo "⚠️ Файл README.md не найден. Создаю..."
touch README.md
fi

Copilot uses AI. Check for mistakes.
if ! grep -q "MetaForge" README.md; then
echo "## MetaForge Activated" >> README.md
echo "- Автоматическое обновление конфигураций." >> README.md
fi

echo "✅ Все потоки активированы. MetaForge в резонансе."
Loading