mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-15 22:32:10 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ef6eb84921 | |||
| f9a1e7c03a | |||
| f9581fa24b | |||
| 0473159b94 | |||
| 81a25b8c56 | |||
| 8e5e4ce530 | |||
| 92940a4d46 | |||
| e6d3492790 | |||
| d6b33cc614 | |||
| b107f01208 | |||
| 22b33fa984 | |||
| f6ccdb3e34 | |||
| 1f271b4c71 |
@@ -1,32 +0,0 @@
|
|||||||
# Python
|
|
||||||
__pycache__
|
|
||||||
*.py[cod]
|
|
||||||
*.pyo
|
|
||||||
*.pyd
|
|
||||||
*.so
|
|
||||||
|
|
||||||
# VCS/CI
|
|
||||||
.git
|
|
||||||
.gitignore
|
|
||||||
.gitattributes
|
|
||||||
.github
|
|
||||||
|
|
||||||
# Editor
|
|
||||||
.vscode
|
|
||||||
.idea
|
|
||||||
|
|
||||||
# Python tooling
|
|
||||||
.pytest_cache
|
|
||||||
.mypy_cache
|
|
||||||
.ruff_cache
|
|
||||||
.tox
|
|
||||||
dist
|
|
||||||
build
|
|
||||||
*.egg-info
|
|
||||||
|
|
||||||
# Local assets
|
|
||||||
logs
|
|
||||||
music
|
|
||||||
data
|
|
||||||
*.env
|
|
||||||
*.env.*
|
|
||||||
@@ -10,8 +10,8 @@ import discord
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from discord.ext import commands, tasks
|
from discord.ext import commands, tasks
|
||||||
|
|
||||||
from ai_functions import get_random_cyclic_message
|
from conjurer.backup_old_docker.ai_functions import get_random_cyclic_message
|
||||||
from constants import (
|
from conjurer.backup_old_docker.constants import (
|
||||||
ENCODING,
|
ENCODING,
|
||||||
LAST_SPONTANEOUS_CALL,
|
LAST_SPONTANEOUS_CALL,
|
||||||
LOGFILE,
|
LOGFILE,
|
||||||
|
|||||||
+3
-3
@@ -10,11 +10,11 @@ import discord
|
|||||||
import openai
|
import openai
|
||||||
import requests
|
import requests
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from other_functions import discord_friendly_send, discord_friendly_reply
|
from conjurer.backup_old_docker.other_functions import discord_friendly_send, discord_friendly_reply
|
||||||
|
|
||||||
|
|
||||||
import ai_functions
|
import conjurer.backup_old_docker.ai_functions as ai_functions
|
||||||
from constants import (
|
from conjurer.backup_old_docker.constants import (
|
||||||
ASSISTANTS,
|
ASSISTANTS,
|
||||||
DATA,
|
DATA,
|
||||||
GRAPHICS_PATH,
|
GRAPHICS_PATH,
|
||||||
|
|||||||
+2
-2
@@ -6,8 +6,8 @@ import random
|
|||||||
import openai
|
import openai
|
||||||
import tiktoken
|
import tiktoken
|
||||||
import time
|
import time
|
||||||
from other_functions import discord_friendly_send
|
from conjurer.backup_old_docker.other_functions import discord_friendly_send
|
||||||
from constants import (
|
from conjurer.backup_old_docker.constants import (
|
||||||
ASSISTANTS,
|
ASSISTANTS,
|
||||||
CYCLIC_WORDS,
|
CYCLIC_WORDS,
|
||||||
ENCODING,
|
ENCODING,
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
version: "3.9"
|
|
||||||
|
|
||||||
services:
|
|
||||||
bot:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: docker/Dockerfile.bot
|
|
||||||
container_name: conjurer-bot
|
|
||||||
env_file:
|
|
||||||
- docker/env/bot.env
|
|
||||||
volumes:
|
|
||||||
- ./docker/volumes/bot/config:/data/config
|
|
||||||
- ./docker/volumes/bot/logs:/data/logs
|
|
||||||
depends_on:
|
|
||||||
- musician
|
|
||||||
- librarian
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "5000:5000"
|
|
||||||
|
|
||||||
musician:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: docker/Dockerfile.musician
|
|
||||||
container_name: conjurer-musician
|
|
||||||
env_file:
|
|
||||||
- docker/env/musician.env
|
|
||||||
volumes:
|
|
||||||
- ./docker/volumes/musician/data:/data
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "5001:5000"
|
|
||||||
|
|
||||||
librarian:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: docker/Dockerfile.librarian
|
|
||||||
container_name: conjurer-librarian
|
|
||||||
env_file:
|
|
||||||
- docker/env/librarian.env
|
|
||||||
volumes:
|
|
||||||
- ./docker/volumes/librarian/data:/data
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "5002:5001"
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
FROM python:3.11-slim
|
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED=1 \
|
|
||||||
PIP_NO_CACHE_DIR=1
|
|
||||||
|
|
||||||
RUN apt-get update \
|
|
||||||
&& apt-get install -y --no-install-recommends \
|
|
||||||
ffmpeg \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY requirements_bot.txt /tmp/requirements.txt
|
|
||||||
RUN pip install -r /tmp/requirements.txt
|
|
||||||
|
|
||||||
COPY . /app
|
|
||||||
|
|
||||||
RUN useradd --create-home appuser \
|
|
||||||
&& chown -R appuser:appuser /app
|
|
||||||
|
|
||||||
USER appuser
|
|
||||||
|
|
||||||
CMD ["python", "thin_client.py"]
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
FROM python:3.11-slim
|
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED=1 \
|
|
||||||
PIP_NO_CACHE_DIR=1
|
|
||||||
|
|
||||||
RUN apt-get update \
|
|
||||||
&& apt-get install -y --no-install-recommends \
|
|
||||||
build-essential \
|
|
||||||
poppler-utils \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY conjurer_librarian/requirements_librarian.txt /tmp/requirements.txt
|
|
||||||
RUN pip install -r /tmp/requirements.txt
|
|
||||||
|
|
||||||
COPY . /app
|
|
||||||
|
|
||||||
RUN useradd --create-home appuser \
|
|
||||||
&& chown -R appuser:appuser /app
|
|
||||||
|
|
||||||
USER appuser
|
|
||||||
|
|
||||||
CMD ["python", "-m", "conjurer_librarian.conjurer_librarian"]
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
FROM python:3.11-slim
|
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED=1 \
|
|
||||||
PIP_NO_CACHE_DIR=1
|
|
||||||
|
|
||||||
RUN apt-get update \
|
|
||||||
&& apt-get install -y --no-install-recommends \
|
|
||||||
ffmpeg \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY requirements_bot.txt /tmp/requirements.txt
|
|
||||||
RUN pip install -r /tmp/requirements.txt
|
|
||||||
|
|
||||||
COPY . /app
|
|
||||||
|
|
||||||
RUN useradd --create-home appuser \
|
|
||||||
&& chown -R appuser:appuser /app
|
|
||||||
|
|
||||||
USER appuser
|
|
||||||
|
|
||||||
CMD ["python", "-m", "conjurer_musician.conjurer_musician"]
|
|
||||||
Vendored
-24
@@ -1,24 +0,0 @@
|
|||||||
# Discord bot service configuration
|
|
||||||
|
|
||||||
DISCORD_TOKEN=HACKME!
|
|
||||||
OPENAI_API_KEY=HACKME!
|
|
||||||
CONJURER_API_KEY=HACKME!
|
|
||||||
|
|
||||||
# Internal service endpoints
|
|
||||||
CONJURER_FILE_SERVICE=http://conjurer-musician:5000
|
|
||||||
CONJURER_LIBRARIAN_SERVICE=http://conjurer-librarian:5001
|
|
||||||
|
|
||||||
# Runtime paths mounted via docker-compose volumes
|
|
||||||
CONJURER_BASE_DIR=/data/config
|
|
||||||
CONJURER_SETTINGS_FILE=/data/config/settings.json
|
|
||||||
CONJURER_MEMORY_FILE=/data/config/pamiec.json
|
|
||||||
CONJURER_MUSIC_MEMORY_FILE=/data/config/pamiec_muzyki.json
|
|
||||||
CONJURER_SYSTEM_GPT_SETTINGS=/data/config/system_gpt_settings.json
|
|
||||||
CONJURER_GRAPHICS_PATH=/data/assets/graphics
|
|
||||||
CONJURER_LOG_FILE=/data/logs/discord.log
|
|
||||||
CONJURER_LOGSTORE=/data/logs
|
|
||||||
|
|
||||||
# Optional external integrations
|
|
||||||
CONJURER_NETRC_FILE=/data/secrets/.netrc
|
|
||||||
YOUTUBE_USERNAME=HACKME!
|
|
||||||
YOUTUBE_PASSWORD=HACKME!
|
|
||||||
Vendored
-14
@@ -1,14 +0,0 @@
|
|||||||
# Librarian service configuration
|
|
||||||
|
|
||||||
CONJURER_API_KEY=HACKME!
|
|
||||||
|
|
||||||
CONJURER_MAIN_BOT=http://conjurer-bot:5000
|
|
||||||
|
|
||||||
CONJURER_LIBRARIAN_HOST=0.0.0.0
|
|
||||||
CONJURER_LIBRARIAN_PORT=5001
|
|
||||||
CONJURER_LIBRARIAN_MAX_RESULTS=500
|
|
||||||
|
|
||||||
CONJURER_CROSSREF_MAILTO=HACKME!
|
|
||||||
CONJURER_LIBRARIAN_LOG=/data/logs/librarian.log
|
|
||||||
|
|
||||||
CONJURER_NETRC_FILE=/data/secrets/.netrc
|
|
||||||
Vendored
-20
@@ -1,20 +0,0 @@
|
|||||||
# Musician service configuration
|
|
||||||
|
|
||||||
CONJURER_API_KEY=HACKME!
|
|
||||||
|
|
||||||
CONJURER_MAIN_BOT=http://conjurer-bot:5000
|
|
||||||
CONJURER_MUSIC_TRACKER_ENDPOINT=/prepped_tracks
|
|
||||||
|
|
||||||
CONJURER_MUSICIAN_HOST=0.0.0.0
|
|
||||||
CONJURER_MUSICIAN_PORT=5000
|
|
||||||
|
|
||||||
CONJURER_MUSIC_FOLDER=/data/music
|
|
||||||
CONJURER_PRIORITY_FOLDER=/data/priority
|
|
||||||
CONJURER_ALL_PLAYLIST=/data/playlists/all_playlist.playlist
|
|
||||||
CONJURER_HIT_PLAYLIST=/data/playlists/hit.playlist
|
|
||||||
CONJURER_REQUEST_PLAYLIST=/data/playlists/request.playlist
|
|
||||||
CONJURER_PRIORITY_PLAYLIST=/data/playlists/priority_queue.playlist
|
|
||||||
CONJURER_STREAM_TEMPLATE=/data/templates/stream.html
|
|
||||||
|
|
||||||
CONJURER_RADIO_LOG=/data/logs/radio.log
|
|
||||||
CONJURER_PERSISTENCE_LOG=/data/logs/persistence.log
|
|
||||||
@@ -81,7 +81,7 @@ sudo apt-get install docker-compose-plugin
|
|||||||
`/mnt/conjurer`.
|
`/mnt/conjurer`.
|
||||||
5. Start only the musician service:
|
5. Start only the musician service:
|
||||||
```bash
|
```bash
|
||||||
docker compose --profile musician up --build -d musician
|
docker compose up --build -d musician
|
||||||
```
|
```
|
||||||
Alternatively, duplicate `docker-compose.yml`, strip other services, and run
|
Alternatively, duplicate `docker-compose.yml`, strip other services, and run
|
||||||
`docker compose up -d`.
|
`docker compose up -d`.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
import file_search_functions
|
import conjurer.backup_old_docker.file_search_functions as file_search_functions
|
||||||
|
|
||||||
class FileSelectView(discord.ui.View):
|
class FileSelectView(discord.ui.View):
|
||||||
def __init__(self, files):
|
def __init__(self, files):
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ sudo apt-get install python3-dev
|
|||||||
sudo apt-get install portaudio19-dev python3-pyaudio
|
sudo apt-get install portaudio19-dev python3-pyaudio
|
||||||
sudo apt-get install
|
sudo apt-get install
|
||||||
cd /home/pi || exit
|
cd /home/pi || exit
|
||||||
mdkir Conjurer
|
mkdir Conjurer
|
||||||
cd Conjurer ||exit
|
cd Conjurer ||exit
|
||||||
python3 -m venv /home/pi/Conjurer/.env
|
python3 -m venv /home/pi/Conjurer/.env
|
||||||
cp /home/pi/conjurer/requirements_bot.txt /home/pi/Conjurer/
|
cp /home/pi/conjurer/requirements_bot.txt /home/pi/Conjurer/
|
||||||
|
|||||||
+2
-2
@@ -10,7 +10,7 @@ import discord
|
|||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
from constants import (
|
from conjurer.backup_old_docker.constants import (
|
||||||
ALLOWED_ROLES,
|
ALLOWED_ROLES,
|
||||||
GUILD_ID,
|
GUILD_ID,
|
||||||
LATEX_MAX_ATTACH_MB,
|
LATEX_MAX_ATTACH_MB,
|
||||||
@@ -19,7 +19,7 @@ from constants import (
|
|||||||
LATEX_TEX_ENGINE,
|
LATEX_TEX_ENGINE,
|
||||||
OPENAI_MODEL,
|
OPENAI_MODEL,
|
||||||
)
|
)
|
||||||
from latex_functions import (
|
from conjurer.backup_old_docker.latex_functions import (
|
||||||
compile_single_tex_bytes,
|
compile_single_tex_bytes,
|
||||||
compile_zip_to_zip,
|
compile_zip_to_zip,
|
||||||
is_safe_asset_name,
|
is_safe_asset_name,
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ import PyPDF2
|
|||||||
import requests
|
import requests
|
||||||
from discord.ext import commands, tasks
|
from discord.ext import commands, tasks
|
||||||
|
|
||||||
from ai_functions import handle_response
|
from conjurer.backup_old_docker.ai_functions import handle_response
|
||||||
from communication_subroutine import IN_COMM_Q, OUT_COMM_Q, QueryControl
|
from conjurer.backup_old_docker.communication_subroutine import IN_COMM_Q, OUT_COMM_Q, QueryControl
|
||||||
from constants import (
|
from conjurer.backup_old_docker.constants import (
|
||||||
DIR_PATH_SADOX,
|
DIR_PATH_SADOX,
|
||||||
LIBRARIAN_SERVICE_ADDRESS,
|
LIBRARIAN_SERVICE_ADDRESS,
|
||||||
SEND_QUERY,
|
SEND_QUERY,
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ import discord
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
import yt_dlp
|
import yt_dlp
|
||||||
from constants import (
|
from conjurer.backup_old_docker.constants import (
|
||||||
FILE_SERVICE_ADDRESS,
|
FILE_SERVICE_ADDRESS,
|
||||||
GET_MP3,
|
GET_MP3,
|
||||||
GET_PLAYLIST,
|
GET_PLAYLIST,
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ from typing import Optional
|
|||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
from constants import ACCIDENT_LOG, DATA, ENCODING
|
from conjurer.backup_old_docker.constants import ACCIDENT_LOG, DATA, ENCODING
|
||||||
|
|
||||||
historia_fabryczki = DATA["fabryczka"]
|
historia_fabryczki = DATA["fabryczka"]
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ import uuid
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from constants import (
|
from conjurer.backup_old_docker.constants import (
|
||||||
RADIO_HARBOR_ADDRESS,
|
RADIO_HARBOR_ADDRESS,
|
||||||
SKIP_TRACK,
|
SKIP_TRACK,
|
||||||
FILE_SERVICE_ADDRESS,
|
FILE_SERVICE_ADDRESS,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ tiktoken
|
|||||||
PyNaCl
|
PyNaCl
|
||||||
flask[async]
|
flask[async]
|
||||||
waitress
|
waitress
|
||||||
clickupython
|
|
||||||
assemblyai[extras]
|
assemblyai[extras]
|
||||||
SpeechRecognition
|
SpeechRecognition
|
||||||
git+https://github.com/imayhaveborkedit/discord-ext-voice-recvO
|
git+https://github.com/imayhaveborkedit/discord-ext-voice-recvO
|
||||||
@@ -15,7 +15,6 @@ PyNaCl
|
|||||||
flask[async]
|
flask[async]
|
||||||
PyMuPDF
|
PyMuPDF
|
||||||
waitress
|
waitress
|
||||||
clickupython
|
|
||||||
assemblyai[extras]
|
assemblyai[extras]
|
||||||
SpeechRecognition
|
SpeechRecognition
|
||||||
git+https://github.com/imayhaveborkedit/discord-ext-voice-recv
|
git+https://github.com/imayhaveborkedit/discord-ext-voice-recv
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
name,type,locations,ap_head,ap_body,ap_larm,ap_rarm,ap_lleg,ap_rleg,max_ag,traits,weight,availability,source,notes
|
|
||||||
Flak Vest,armor,"Body",0,4,0,0,0,0,,Flak,7,Common,"DH2 CRB","PRZYKŁAD – ZASTĄP"
|
|
||||||
Power Armour (Astartes),armor,"All",8,10,8,8,9,9,,Environmental; Auto-senses,100,"Very Rare","DW CRB","PRZYKŁAD – ZASTĄP"
|
|
||||||
|
@@ -1,60 +0,0 @@
|
|||||||
// DH2 Attack Test v2 — presets: Aim/Range/Fire + Size/Light/Cover
|
|
||||||
const actor = canvas.tokens.controlled[0]?.actor ?? game.user.character;
|
|
||||||
if (!actor) return ui.notifications.warn("Zaznacz token albo przypisz postać.");
|
|
||||||
new Dialog({
|
|
||||||
title: "🎯 Attack Test (WS/BS)",
|
|
||||||
content: `
|
|
||||||
<form>
|
|
||||||
<div class="form-group"><label>Base Target (WS/BS)</label><input name="base" type="number" value="40"/></div>
|
|
||||||
<div class="form-group"><label>Aim</label>
|
|
||||||
<select name="aim"><option value="0">None</option><option value="10">Half (+10)</option><option value="20">Full (+20)</option></select></div>
|
|
||||||
<div class="form-group"><label>Range</label>
|
|
||||||
<select name="range">
|
|
||||||
<option value="0">Standard</option>
|
|
||||||
<option value="30">Point Blank (+30)</option>
|
|
||||||
<option value="10">Short (+10)</option>
|
|
||||||
<option value="-10">Long (-10)</option>
|
|
||||||
<option value="-30">Extreme (-30)</option>
|
|
||||||
</select></div>
|
|
||||||
<div class="form-group"><label>Fire / Attack</label>
|
|
||||||
<select name="stance">
|
|
||||||
<option value="0">Standard / Single</option>
|
|
||||||
<option value="10">Semi (+10)</option>
|
|
||||||
<option value="-10">Full Auto (-10)</option>
|
|
||||||
<option value="30">All Out (Melee +30)</option>
|
|
||||||
</select></div>
|
|
||||||
<div class="form-group"><label>Target Size</label>
|
|
||||||
<select name="size">
|
|
||||||
<option value="0">Average</option>
|
|
||||||
<option value="10">Hulking (+10)</option>
|
|
||||||
<option value="20">Enormous (+20)</option>
|
|
||||||
<option value="30">Massive (+30)</option>
|
|
||||||
<option value="-10">Puny (-10)</option>
|
|
||||||
</select></div>
|
|
||||||
<div class="form-group"><label>Lighting</label>
|
|
||||||
<select name="light"><option value="0">Normal</option><option value="10">Good (+10)</option><option value="-10">Poor (-10)</option></select></div>
|
|
||||||
<div class="form-group"><label>Cover</label>
|
|
||||||
<select name="cover"><option value="0">None</option><option value="-10">Light (-10)</option><option value="-20">Heavy (-20)</option></select></div>
|
|
||||||
<div class="form-group"><label>Other Modifiers</label><input name="mod" type="number" value="0"/></div>
|
|
||||||
</form>`,
|
|
||||||
buttons: {
|
|
||||||
roll: {
|
|
||||||
label: "Roll",
|
|
||||||
callback: async (html) => {
|
|
||||||
const get = n => Number(html.find(`[name="${n}"]`).val());
|
|
||||||
const base = get("base");
|
|
||||||
const total = base + get("aim") + get("range") + get("stance") + get("size") + get("light") + get("cover") + get("mod");
|
|
||||||
const r = await(new Roll("1d100")).roll({async:true});
|
|
||||||
const ok = r.total <= total;
|
|
||||||
const margin = Math.abs(total - r.total);
|
|
||||||
const dox = ok ? 1 + Math.floor(margin/10) : Math.floor(margin/10);
|
|
||||||
const table = `
|
|
||||||
<table style="width:100%;border-collapse:collapse">
|
|
||||||
<tr><td><b>Target</b></td><td>${total}</td><td><b>Roll</b></td><td>${r.total}</td></tr>
|
|
||||||
<tr><td><b>Result</b></td><td colspan="3">${ok?'<span style="color:green">SUCCESS</span>':'<span style="color:red">FAIL</span>'} — ${ok?dox+' DoS':dox+' DoF'}</td></tr>
|
|
||||||
</table>`;
|
|
||||||
r.toMessage({speaker: ChatMessage.getSpeaker({actor}), flavor: `🎯 <b>Attack Test</b><br/>${table}`});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).render(true);
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
Roll,Result
|
|
||||||
1,Energy/Head — wpis 1
|
|
||||||
2,Energy/Head — wpis 2
|
|
||||||
3,Energy/Head — wpis 3
|
|
||||||
4,Energy/Head — wpis 4
|
|
||||||
5,Energy/Head — wpis 5
|
|
||||||
|
@@ -1,50 +0,0 @@
|
|||||||
// 🧠 Focus Power (DH2) — WP test + Phenomena/Perils with mode presets
|
|
||||||
const actor = canvas.tokens.controlled[0]?.actor ?? game.user.character;
|
|
||||||
if (!actor) return ui.notifications.warn("Zaznacz token.");
|
|
||||||
new Dialog({
|
|
||||||
title: "🧠 Focus Power",
|
|
||||||
content: `
|
|
||||||
<form>
|
|
||||||
<div class="form-group"><label>Willpower (target)</label><input name="wp" type="number" value="40"/></div>
|
|
||||||
<div class="form-group"><label>Psychic Rating (PR)</label><input name="pr" type="number" value="3"/></div>
|
|
||||||
<div class="form-group"><label>Mode</label>
|
|
||||||
<select name="mode"><option value="fettered">Fettered (no PP; PR/2)</option><option value="unfettered" selected>Unfettered (PP on doubles)</option><option value="push">Push (always PP; +PR)</option></select></div>
|
|
||||||
<div class="form-group"><label>Power difficulty/gear/etc. (flat mod)</label><input name="flat" type="number" value="0"/></div>
|
|
||||||
<div class="form-group"><label>Perils threshold</label><input name="thr" type="number" value="75"/></div>
|
|
||||||
</form>`,
|
|
||||||
buttons: {
|
|
||||||
roll: { label: "Roll", callback: async html => {
|
|
||||||
const wp = Number(html.find('[name="wp"]').val());
|
|
||||||
const pr = Number(html.find('[name="pr"]').val());
|
|
||||||
const mode = html.find('[name="mode"]').val();
|
|
||||||
const flat = Number(html.find('[name="flat"]').val());
|
|
||||||
const thr = Number(html.find('[name="thr"]').val());
|
|
||||||
let effPR = pr, ppmod = 0, ppAlways = false, note = "";
|
|
||||||
if (mode==="fettered"){ effPR = Math.max(1, Math.floor(pr/2)); note="(Fettered: PR/2, brak Phenomena)"; }
|
|
||||||
if (mode==="push"){ effPR = pr+3; ppmod=10; ppAlways = true; note="(Push: +3 PR, Phenomena zawsze, +10)"; }
|
|
||||||
const target = wp + flat;
|
|
||||||
const roll = await (new Roll("1d100")).roll({async:true});
|
|
||||||
const ok = roll.total <= target;
|
|
||||||
const dos = ok ? 1 + Math.floor((target - roll.total)/10) : Math.floor((roll.total - target)/10);
|
|
||||||
const doubles = (roll.total%11===0) || (roll.total===100);
|
|
||||||
const info = `<table style="width:100%;border-collapse:collapse">
|
|
||||||
<tr><td><b>Target</b></td><td>${target}</td><td><b>Roll</b></td><td>${roll.total}</td></tr>
|
|
||||||
<tr><td><b>Result</b></td><td colspan="3">${ok?'<span style="color:green">SUCCESS</span>':'<span style="color:red">FAIL</span>'} — ${ok?dos+' DoS':dos+' DoF'} ${doubles?' — <b>DOUBLES</b>':''}</td></tr>
|
|
||||||
<tr><td><b>Eff. PR</b></td><td>${effPR}</td><td><b>Range hint</b></td><td>${effPR*10} m (jeśli moc tak działa)</td></tr>
|
|
||||||
</table>`;
|
|
||||||
roll.toMessage({speaker: ChatMessage.getSpeaker({actor}), flavor:`🧠 <b>Focus Power</b> ${note}<br/>${info}`});
|
|
||||||
const needPP = (mode==="unfettered" && doubles) || (mode==="push") ;
|
|
||||||
if (needPP){
|
|
||||||
const tbl = game.tables.getName("Psychic Phenomena");
|
|
||||||
if (tbl){
|
|
||||||
const r = await (new Roll(`1d100 + ${ppmod}`)).roll({async:true});
|
|
||||||
await tbl.draw({displayResults:true, roll:r});
|
|
||||||
if (r.total >= thr){
|
|
||||||
const per = game.tables.getName("Perils of the Warp");
|
|
||||||
if (per) await per.draw({displayResults:true});
|
|
||||||
}
|
|
||||||
} else ChatMessage.create({content:"Utwórz RollTable: <b>Psychic Phenomena</b> (+ <b>Perils of the Warp</b>)"});
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
}).render(true);
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
// 🎯 Hit Location (DH mapping by reversed roll)
|
|
||||||
new Dialog({
|
|
||||||
title:"🎯 Hit Location",
|
|
||||||
content:`<form>
|
|
||||||
<div class="form-group"><label>Attack d100 roll</label><input name="roll" type="number" value="37"/></div>
|
|
||||||
</form>`,
|
|
||||||
buttons:{
|
|
||||||
go:{label:"Resolve", callback: html=>{
|
|
||||||
const n = Math.max(1, Math.min(100, Number(html.find('[name="roll"]').val())));
|
|
||||||
const rev = Number(String(n).padStart(2,"0").split("").reverse().join(""));
|
|
||||||
let loc = "";
|
|
||||||
if (rev<=10) loc="Head";
|
|
||||||
else if (rev<=20) loc="Right Arm";
|
|
||||||
else if (rev<=30) loc="Left Arm";
|
|
||||||
else if (rev<=70) loc="Body";
|
|
||||||
else if (rev<=85) loc="Right Leg";
|
|
||||||
else loc="Left Leg";
|
|
||||||
ChatMessage.create({content:`🎯 <b>Hit Location</b>: roll ${n} → reversed ${rev} → <b>${loc}</b>`});
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
}).render(true);
|
|
||||||
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
const text=`<b>House Rules — DH2 chassis</b><br/>
|
|
||||||
• Unnatural mapowanie: dawne ×2 bonus → Unnatural (+X) tak, by SB/TB odzwierciedlały linię źródłową.<br/>
|
|
||||||
• Pancerz Astartes: zachowaj AP; zużycie zasilania jako +1 Fatigue co X scen zamiast liczenia minut.<br/>
|
|
||||||
• Aptitudes: archetypy z RT/DW/BC mają przypisane 2–3 Aptitudes DH2 dla kosztów XP.<br/>
|
|
||||||
• Psy: testy i PR z DH2 dla wszystkich; GK posiada Aegis Discipline (1×/scena reroll Perils) + 1–2 signature powers z DW.<br/>
|
|
||||||
• RT Acquisition → DH2 Influence z modyfikatorami kontekstowymi (teatr działań, mandat Inkwizycji, czas).`;ChatMessage.create({content:text});
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
// 🚦 Initiative for selected tokens (1d10 + AG Bonus prompt)
|
|
||||||
if (!canvas.tokens.controlled.length) return ui.notifications.warn("Zaznacz co najmniej jeden token.");
|
|
||||||
const combat = game.combat ?? await Combat.implementation.create({});
|
|
||||||
for (const t of canvas.tokens.controlled){
|
|
||||||
if (!combat.combatants.some(c=>c.tokenId===t.id)) await combat.createEmbeddedDocuments("Combatant",[ {tokenId:t.id, sceneId: canvas.scene.id, hidden:false} ]);
|
|
||||||
const ag = Number(await Dialog.prompt({title:`AG Bonus for ${t.name}`, content:`<input type="number" value="4">`, label:"OK"}));
|
|
||||||
const r = await (new Roll(`1d10 + ${ag}`)).roll({async:true});
|
|
||||||
await combat.setInitiative(combat.combatants.find(c=>c.tokenId===t.id).id, r.total);
|
|
||||||
r.toMessage({flavor:`🚦 <b>Initiative</b> — ${t.name}: ${r.total}`});
|
|
||||||
}
|
|
||||||
ui.notifications.info("Inicjatywy ustawione.");
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
Roll,Result
|
|
||||||
1-5,Perils 1–5 — WPISZ
|
|
||||||
6-10,Perils 6–10 — WPISZ
|
|
||||||
11-15,Perils 11–15 — WPISZ
|
|
||||||
16-20,Perils 16–20 — WPISZ
|
|
||||||
21-25,Perils 21–25 — WPISZ
|
|
||||||
26-30,Perils 26–30 — WPISZ
|
|
||||||
31-35,Perils 31–35 — WPISZ
|
|
||||||
36-40,Perils 36–40 — WPISZ
|
|
||||||
41-45,Perils 41–45 — WPISZ
|
|
||||||
46-50,Perils 46–50 — WPISZ
|
|
||||||
51-55,Perils 51–55 — WPISZ
|
|
||||||
56-60,Perils 56–60 — WPISZ
|
|
||||||
61-65,Perils 61–65 — WPISZ
|
|
||||||
66-70,Perils 66–70 — WPISZ
|
|
||||||
71-75,Perils 71–75 — WPISZ
|
|
||||||
76-80,Perils 76–80 — WPISZ
|
|
||||||
81-85,Perils 81–85 — WPISZ
|
|
||||||
86-90,Perils 86–90 — WPISZ
|
|
||||||
91-95,Perils 91–95 — WPISZ
|
|
||||||
96-100,Perils 96–100 — WPISZ
|
|
||||||
|
@@ -1,3 +0,0 @@
|
|||||||
name,type,discipline,action,test,range,sustained,effect,source,notes
|
|
||||||
Smite,power,Biomancy,Half,"WP Challenging (+0)","PR*10m",No,"1d10+PR E; Tearing","DH2 CRB","PRZYKŁAD – ZASTĄP"
|
|
||||||
Foreboding,power,Divination,Reaction,"Per Difficult (-10)","Self",No,"Use as Evasion; DoS rules","DH2 CRB","PRZYKŁAD – ZASTĄP"
|
|
||||||
|
-21
@@ -1,21 +0,0 @@
|
|||||||
Roll,Result
|
|
||||||
1-5,PP 1–5 — WPISZ
|
|
||||||
6-10,PP 6–10 — WPISZ
|
|
||||||
11-15,PP 11–15 — WPISZ
|
|
||||||
16-20,PP 16–20 — WPISZ
|
|
||||||
21-25,PP 21–25 — WPISZ
|
|
||||||
26-30,PP 26–30 — WPISZ
|
|
||||||
31-35,PP 31–35 — WPISZ
|
|
||||||
36-40,PP 36–40 — WPISZ
|
|
||||||
41-45,PP 41–45 — WPISZ
|
|
||||||
46-50,PP 46–50 — WPISZ
|
|
||||||
51-55,PP 51–55 — WPISZ
|
|
||||||
56-60,PP 56–60 — WPISZ
|
|
||||||
61-65,PP 61–65 — WPISZ
|
|
||||||
66-70,PP 66–70 — WPISZ
|
|
||||||
71-75,PP 71–75 — WPISZ
|
|
||||||
76-80,PP 76–80 — WPISZ
|
|
||||||
81-85,PP 81–85 — WPISZ
|
|
||||||
86-90,PP 86–90 — WPISZ
|
|
||||||
91-95,PP 91–95 — WPISZ
|
|
||||||
96-100,PP 96–100 — WPISZ
|
|
||||||
|
@@ -1,28 +0,0 @@
|
|||||||
// 🩹 Toggle conditions on selected tokens (Foundry v13)
|
|
||||||
const choices = [
|
|
||||||
{id:"fatigued", label:"Fatigued"},
|
|
||||||
{id:"stunned", label:"Stunned"},
|
|
||||||
{id:"prone", label:"Prone"},
|
|
||||||
{id:"frightened", label:"Frightened (Fear)"}
|
|
||||||
];
|
|
||||||
const opts = choices.map(c=>`<label><input type="checkbox" name="c" value="${c.id}"> ${c.label}</label>`).join("<br/>");
|
|
||||||
new Dialog({
|
|
||||||
title:"🩹 Conditions",
|
|
||||||
content:`<form>${opts}<div class="form-group"><label>Mode</label>
|
|
||||||
<select name="mode"><option value="toggle">Toggle</option><option value="on">Apply</option><option value="off">Remove</option></select></div></form>`,
|
|
||||||
buttons:{
|
|
||||||
go:{label:"Apply",callback: html=>{
|
|
||||||
const ids = Array.from(html.find('input[name="c"]:checked')).map(e=>e.value);
|
|
||||||
const mode = html.find('[name="mode"]').val();
|
|
||||||
const getEf = id => CONFIG.statusEffects.find(e=>e.id===id) ?? {id};
|
|
||||||
canvas.tokens.controlled.forEach(t=>{
|
|
||||||
ids.forEach(id=>{
|
|
||||||
if (mode==="toggle") t.toggleEffect(getEf(id));
|
|
||||||
else if (mode==="on") t.actor?.effects?.some(e=>e.getFlag("core","statusId")===id) ? null : t.toggleEffect(getEf(id));
|
|
||||||
else if (mode==="off") t.actor?.effects?.some(e=>e.getFlag("core","statusId")===id) ? t.toggleEffect(getEf(id)) : null;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
}).render(true);
|
|
||||||
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
// 💥 Quick Damage — supports Tearing, Proven(X), Primitive(X), flat mod
|
|
||||||
new Dialog({
|
|
||||||
title:"💥 Damage Roller",
|
|
||||||
content: `
|
|
||||||
<form>
|
|
||||||
<div class="form-group"><label>Flat modifier (e.g., +3)</label><input name="mod" type="number" value="0"/></div>
|
|
||||||
<div class="form-group"><label>Traits</label>
|
|
||||||
<label><input type="checkbox" name="tear"> Tearing</label>
|
|
||||||
<label><input type="checkbox" name="prov"> Proven</label>
|
|
||||||
<input name="provV" type="number" value="0" style="width:60px" placeholder="X"/>
|
|
||||||
<label><input type="checkbox" name="prim"> Primitive</label>
|
|
||||||
<input name="primV" type="number" value="0" style="width:60px" placeholder="X"/>
|
|
||||||
</div>
|
|
||||||
</form>`,
|
|
||||||
buttons:{
|
|
||||||
go:{label:"Roll", callback: async html=>{
|
|
||||||
const mod = Number(html.find('[name="mod"]').val());
|
|
||||||
const tearing = html.find('[name="tear"]')[0].checked;
|
|
||||||
const proven = html.find('[name="prov"]')[0].checked ? Number(html.find('[name="provV"]').val()) : 0;
|
|
||||||
const primitive = html.find('[name="prim"]')[0].checked ? Number(html.find('[name="primV"]').val()) : 0;
|
|
||||||
// base die (d10) with tearing (best of 2)
|
|
||||||
const r1 = await (new Roll("1d10")).roll({async:true});
|
|
||||||
const r2 = tearing ? await (new Roll("1d10")).roll({async:true}) : null;
|
|
||||||
let die = tearing ? Math.max(r1.total, r2.total) : r1.total;
|
|
||||||
// apply Proven/Primitive
|
|
||||||
if (proven>0) die = Math.max(die, proven);
|
|
||||||
if (primitive>0) die = Math.min(die, primitive);
|
|
||||||
const rf = (die===10); // potential Zealous Hatred trigger
|
|
||||||
const total = die + mod;
|
|
||||||
let flavor = `💥 <b>Damage</b><br/>Die: ${die}${tearing?` (Tearing ${r1.total}/${r2.total.total})`:''} + Mod ${mod} = <b>${total}</b>`;
|
|
||||||
if (proven>0) flavor += `<br/>Proven(${proven}) zastosowano`;
|
|
||||||
if (primitive>0) flavor += `<br/>Primitive(${primitive}) zastosowano`;
|
|
||||||
if (rf) flavor += `<br/><b>⚡ Natural 10</b> — rozważ Zealous Hatred.`;
|
|
||||||
ChatMessage.create({speaker: ChatMessage.getSpeaker(), content: flavor});
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
}).render(true);
|
|
||||||
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
// 📚 Create placeholder RollTables for Crits + Psychic Phenomena/Perils (with icons)
|
|
||||||
const icon = {Energy:"⚡", Impact:"🔨", Rending:"🗡️", Explosive:"💥"};
|
|
||||||
const dmgTypes = ["Energy","Impact","Rending","Explosive"];
|
|
||||||
const locs = ["Head","Body","Left Arm","Right Arm","Left Leg","Right Leg"];
|
|
||||||
async function makeCrit(dtype, loc){
|
|
||||||
const name = `Crit: ${dtype} - ${loc}`;
|
|
||||||
if (game.tables.getName(name)) return;
|
|
||||||
const results = [];
|
|
||||||
for (let i=1;i<=5;i++){
|
|
||||||
results.push({type:0, text:`${icon[dtype]||""} ${dtype}/${loc} — wpis ${i} (uzupełnij z PDF)`, weight:1, range:[i,i]});
|
|
||||||
}
|
|
||||||
await RollTable.implementation.create({name, formula:"1d5", replacement:true, displayRoll:false, results});
|
|
||||||
}
|
|
||||||
async function makeWide(name, emoji){
|
|
||||||
if (game.tables.getName(name)) return;
|
|
||||||
const results = [];
|
|
||||||
for (let i=0;i<20;i++){
|
|
||||||
const lo=i*5+1, hi=i*5+5;
|
|
||||||
results.push({type:0, text:`${emoji} ${name} ${lo}-${hi} — wpis (uzupełnij z PDF)`, weight:1, range:[lo,hi]});
|
|
||||||
}
|
|
||||||
await RollTable.implementation.create({name, formula:"1d100", replacement:true, displayRoll:false, results});
|
|
||||||
}
|
|
||||||
for (const d of dmgTypes) for (const l of locs) await makeCrit(d,l);
|
|
||||||
await makeWide("Psychic Phenomena","🌀");
|
|
||||||
await makeWide("Perils of the Warp","☠️");
|
|
||||||
ui.notifications.info("Utworzono puste tabele: Crits (4×6) + Phenomena + Perils.");
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
name,type,tier,aptitudes,prereq,effect,source,notes
|
|
||||||
Ambidextrous,talent,1,"Agility; Offence","Ag 30","-10 to off-hand penalty","DH2 CRB","PRZYKŁAD – ZASTĄP"
|
|
||||||
Aegis Discipline (GK),talent,2,"Willpower; Defence","Psyker","Reroll Perils 1×scene","HOUSE","DODAJ WŁASNY OPIS"
|
|
||||||
|
@@ -1,3 +0,0 @@
|
|||||||
name,type,subtype,damage,pen,range,rof,qualities,weight,availability,source,notes
|
|
||||||
Lasgun M36,weapon,Basic,"1d10+3",0,100m,"S/3/–","Reliable",4,Common,"DH2 CRB p.142","PRZYKŁAD – ZASTĄP"
|
|
||||||
Astartes Bolter,weapon,Basic,"1d10+9",4,90m,"S/2/–","Tearing; Unreliable",9,Rare,"DW CRB","PRZYKŁAD – ZASTĄP"
|
|
||||||
|
@@ -1,33 +0,0 @@
|
|||||||
// ⚡ Zealous Hatred helper (DH2) — roll 1d5 crit OR add +1d5 dmg
|
|
||||||
new Dialog({
|
|
||||||
title: "⚡ Zealous Hatred",
|
|
||||||
content: `
|
|
||||||
<form>
|
|
||||||
<div class="form-group"><label>Wound damage after Armour/TB?</label>
|
|
||||||
<select name="penetrated"><option value="yes">Yes → roll Critical (1d5)</option><option value="no">No → add +1d5 damage</option></select></div>
|
|
||||||
<div class="form-group"><label>Damage Type</label>
|
|
||||||
<select name="dtype"><option>Energy</option><option>Impact</option><option>Rending</option><option>Explosive</option></select></div>
|
|
||||||
<div class="form-group"><label>Hit Location</label>
|
|
||||||
<select name="loc"><option>Head</option><option>Body</option><option>Left Arm</option><option>Right Arm</option><option>Left Leg</option><option>Right Leg</option></select></div>
|
|
||||||
<div class="form-group"><label>Table name (optional override)</label><input name="tname" type="text" placeholder="Crit: Energy - Head"/></div>
|
|
||||||
</form>`,
|
|
||||||
buttons: {
|
|
||||||
go: { label: "Resolve", callback: async html => {
|
|
||||||
const pen = html.find('[name="penetrated"]').val();
|
|
||||||
if (pen === "yes") {
|
|
||||||
const dtype = html.find('[name="dtype"]').val();
|
|
||||||
const loc = html.find('[name="loc"]').val();
|
|
||||||
const override = html.find('[name="tname"]').val()?.trim();
|
|
||||||
const name = override || `Crit: ${dtype} - ${loc}`;
|
|
||||||
const r = await (new Roll("1d5")).roll({async:true});
|
|
||||||
const table = game.tables.getName(name);
|
|
||||||
if (table) await table.draw({displayResults:true, roll:r});
|
|
||||||
else r.toMessage({flavor:`⚡ <b>Zealous Hatred</b>: Critical ${r.total} — brak tabeli <b>${name}</b> (utwórz lub zmień nazwę).`});
|
|
||||||
} else {
|
|
||||||
const r = await (new Roll("1d5")).roll({async:true});
|
|
||||||
r.toMessage({flavor:"⚡ <b>Zealous Hatred</b>: Dodaj do obrażeń <b>+1d5</b> (atak nie przebił Soak)."});
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
}).render(true);
|
|
||||||
|
|
||||||
@@ -0,0 +1,296 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
Buduje nową gałąź z "próbkowanych" commitów na podstawie tagów z bieżącej gałęzi,
|
||||||
|
a na końcu dodaje stan bieżącego HEAD (jeśli nie jest otagowany).
|
||||||
|
Autor: (drop-in)
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from typing import List, Tuple, Optional
|
||||||
|
|
||||||
|
# --- Logging setup ---
|
||||||
|
logger = logging.getLogger("tag_branch_builder")
|
||||||
|
handler = logging.StreamHandler(sys.stdout)
|
||||||
|
formatter = logging.Formatter("%(levelname)s: %(message)s")
|
||||||
|
handler.setFormatter(formatter)
|
||||||
|
logger.addHandler(handler)
|
||||||
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
|
|
||||||
|
class GitError(RuntimeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def run_git(args: List[str], cwd: Optional[str] = None, check: bool = True) -> str:
|
||||||
|
"""Run a git command and return stdout (stripped)."""
|
||||||
|
cmd = ["git"] + args
|
||||||
|
logger.debug("Running: %s", " ".join(cmd))
|
||||||
|
try:
|
||||||
|
proc = subprocess.run(
|
||||||
|
cmd,
|
||||||
|
cwd=cwd,
|
||||||
|
check=False,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception("Nie udało się uruchomić gita.") from e
|
||||||
|
raise
|
||||||
|
|
||||||
|
if check and proc.returncode != 0:
|
||||||
|
logger.error("Git error (%s): %s", " ".join(cmd), proc.stderr.strip())
|
||||||
|
raise GitError(proc.stderr.strip())
|
||||||
|
return proc.stdout.strip()
|
||||||
|
|
||||||
|
|
||||||
|
def ensure_git_repo() -> None:
|
||||||
|
try:
|
||||||
|
run_git(["rev-parse", "--is-inside-work-tree"])
|
||||||
|
except Exception:
|
||||||
|
logger.exception("To nie wygląda na repozytorium git.")
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def ensure_clean_worktree() -> None:
|
||||||
|
# Untracked + changes
|
||||||
|
status = run_git(["status", "--porcelain"])
|
||||||
|
if status.strip():
|
||||||
|
raise GitError(
|
||||||
|
"Drzewo robocze nie jest czyste. Zacommituj/stashuj zmiany i spróbuj ponownie."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def current_branch() -> str:
|
||||||
|
# Returns branch or 'HEAD' when detached
|
||||||
|
ref = run_git(["rev-parse", "--abbrev-ref", "HEAD"])
|
||||||
|
return ref
|
||||||
|
|
||||||
|
|
||||||
|
def head_sha() -> str:
|
||||||
|
return run_git(["rev-parse", "HEAD"])
|
||||||
|
|
||||||
|
|
||||||
|
def sha_has_tag(sha: str) -> List[str]:
|
||||||
|
# tags pointing at sha
|
||||||
|
tags = run_git(["tag", "--points-at", sha])
|
||||||
|
return [t for t in tags.splitlines() if t.strip()]
|
||||||
|
|
||||||
|
|
||||||
|
def tags_merged_into(branch: str) -> List[str]:
|
||||||
|
out = run_git(["tag", "--merged", branch])
|
||||||
|
return [t for t in out.splitlines() if t.strip()]
|
||||||
|
|
||||||
|
|
||||||
|
def tag_commit_sha(tag: str) -> str:
|
||||||
|
return run_git(["rev-list", "-n", "1", tag])
|
||||||
|
|
||||||
|
|
||||||
|
def commit_unix_time(sha: str) -> int:
|
||||||
|
return int(run_git(["show", "-s", "--format=%ct", sha]))
|
||||||
|
|
||||||
|
|
||||||
|
def sort_tags_by_commit_time(tags: List[str]) -> List[Tuple[str, str, int]]:
|
||||||
|
triples = []
|
||||||
|
for t in tags:
|
||||||
|
sha = tag_commit_sha(t)
|
||||||
|
ts = commit_unix_time(sha)
|
||||||
|
triples.append((t, sha, ts))
|
||||||
|
triples.sort(key=lambda x: x[2]) # oldest first
|
||||||
|
return triples
|
||||||
|
|
||||||
|
|
||||||
|
def list_intermediate_messages(old_sha: Optional[str], new_sha: str) -> List[str]:
|
||||||
|
"""
|
||||||
|
Zwróć listę komunikatów commitów POŚREDNICH (wyłącznie) od old_sha do new_sha.
|
||||||
|
Kolejność: od najstarszego do najnowszego.
|
||||||
|
"""
|
||||||
|
if old_sha is None:
|
||||||
|
# Nie ma commitów pośrednich przed pierwszym tagiem
|
||||||
|
return []
|
||||||
|
# ancestry-path: tylko ścieżka od old_sha do new_sha (jeśli wiele rodziców)
|
||||||
|
# Zakres old_sha..new_sha zawiera new_sha, dlatego pominiemy go w output.
|
||||||
|
rng = f"{old_sha}..{new_sha}"
|
||||||
|
try:
|
||||||
|
out = run_git(
|
||||||
|
["log", "--format=%s", "--reverse", "--ancestry-path", rng], check=True
|
||||||
|
)
|
||||||
|
except GitError:
|
||||||
|
# Brak ścieżki (np. tag nie jest potomkiem old_sha) – wtedy nie ma pośrednich
|
||||||
|
return []
|
||||||
|
msgs = [ln for ln in out.splitlines() if ln.strip()]
|
||||||
|
if msgs:
|
||||||
|
# Ostatnia pozycja może być new_sha (w praktyce git log na %s nie odróżnia, ale
|
||||||
|
# jeśli zakres zwróci message z new_sha na końcu, usuniemy go porównując SHA).
|
||||||
|
# Prostsze: usuń ostatni wpis, bo to najnowszy (new_sha).
|
||||||
|
msgs = msgs[:-1]
|
||||||
|
return msgs
|
||||||
|
|
||||||
|
|
||||||
|
def checkout_orphan_branch(new_branch: str) -> None:
|
||||||
|
run_git(["checkout", "--orphan", new_branch])
|
||||||
|
# Usuń wszystko z indeksu i roboczego (z wyjątkiem .git)
|
||||||
|
# Najpierw usuń śledzone:
|
||||||
|
run_git(["rm", "-r", "--quiet", "--cached", "--force", "."], check=False)
|
||||||
|
# Potem pliki robocze:
|
||||||
|
for root, dirs, files in os.walk(".", topdown=False):
|
||||||
|
# pomiń .git
|
||||||
|
if root.startswith("./.git") or root == ".git":
|
||||||
|
continue
|
||||||
|
for name in files:
|
||||||
|
try:
|
||||||
|
os.remove(os.path.join(root, name))
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
for name in dirs:
|
||||||
|
p = os.path.join(root, name)
|
||||||
|
if p == "./.git":
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
os.rmdir(p)
|
||||||
|
except OSError:
|
||||||
|
# Niepuste – to OK, wyczyścimy przy checkout
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def replace_worktree_with_commit(sha: str) -> None:
|
||||||
|
"""
|
||||||
|
Nadpisz zawartość roboczą drzewem z commit-a sha.
|
||||||
|
"""
|
||||||
|
# Najpierw usuń aktualne pliki (również nieśledzone), potem wczytaj tree wybranego commita:
|
||||||
|
# 1) git checkout <sha> -- . (zapisze pliki do working tree + index)
|
||||||
|
# 2) git add -A
|
||||||
|
# Aby dopilnować usunięć: zrób czyszczenie przez git rm -r ., potem checkout.
|
||||||
|
run_git(["rm", "-r", "--quiet", "--ignore-unmatch", "."], check=False)
|
||||||
|
# Przywróć pliki ze wskazanego commita:
|
||||||
|
# Uwaga: jeśli repo ma submoduły/large files – to wykracza poza zakres, ale zadziała dla standardowych plików.
|
||||||
|
run_git(["checkout", sha, "--", "."])
|
||||||
|
run_git(["add", "-A"])
|
||||||
|
|
||||||
|
|
||||||
|
def build_commit_message_for_tag(tag: str, intermediates: List[str]) -> str:
|
||||||
|
if not intermediates:
|
||||||
|
return f"Tag: {tag}"
|
||||||
|
lines = ["Tag: " + tag, "", "Intermediate commits (oldest → newest):"]
|
||||||
|
lines += [f"- {m}" for m in intermediates]
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
|
||||||
|
def build_commit_message_for_head(since_tag: Optional[str], intermediates: List[str]) -> str:
|
||||||
|
title = "HEAD (unreleased)"
|
||||||
|
hdr = title if since_tag is None else f"{title} since tag {since_tag}"
|
||||||
|
if not intermediates:
|
||||||
|
return hdr
|
||||||
|
lines = [hdr, "", "Intermediate commits (oldest → newest):"]
|
||||||
|
lines += [f"- {m}" for m in intermediates]
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
|
||||||
|
def commit_all(message: str) -> None:
|
||||||
|
# Zacommituj wszystko co w indeksie (po replace_worktree_with_commit daliśmy add -A)
|
||||||
|
run_git(["commit", "-m", message])
|
||||||
|
|
||||||
|
|
||||||
|
def push_new_branch(remote_url: str, branch: str) -> None:
|
||||||
|
# Dodaj zdalny 'newrepo' jeśli nie istnieje, ustaw URL i wypchnij
|
||||||
|
remotes = run_git(["remote"]).splitlines()
|
||||||
|
if "newrepo" not in remotes:
|
||||||
|
run_git(["remote", "add", "newrepo", remote_url])
|
||||||
|
else:
|
||||||
|
# podmień URL na wszelki wypadek
|
||||||
|
run_git(["remote", "set-url", "newrepo", remote_url])
|
||||||
|
run_git(["push", "-u", "newrepo", f"{branch}:{branch}"])
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> int:
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Zbuduj nową gałąź na podstawie tagów z bieżącej gałęzi."
|
||||||
|
)
|
||||||
|
parser.add_argument("new_branch", help="Nazwa nowej gałęzi do utworzenia")
|
||||||
|
parser.add_argument(
|
||||||
|
"--new-repo-url",
|
||||||
|
dest="new_repo_url",
|
||||||
|
default=None,
|
||||||
|
help="(Opcjonalnie) adres URL nowego zdalnego repo – zostanie dodany jako 'newrepo' i wykonany push nowej gałęzi.",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-v", "--verbose", action="store_true", help="Bardziej gadatliwe logi"
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.verbose:
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
try:
|
||||||
|
ensure_git_repo()
|
||||||
|
ensure_clean_worktree()
|
||||||
|
base_branch = current_branch()
|
||||||
|
base_head = head_sha()
|
||||||
|
logger.info("Bieżąca gałąź: %s", base_branch)
|
||||||
|
logger.info("HEAD: %s", base_head[:12])
|
||||||
|
|
||||||
|
# Zbierz tagi osiągalne z bieżącej gałęzi
|
||||||
|
merged_tags = tags_merged_into(base_branch)
|
||||||
|
if not merged_tags:
|
||||||
|
logger.warning(
|
||||||
|
"Nie znaleziono tagów osiągalnych z bieżącej gałęzi. Gałąź zostanie zbudowana tylko z HEAD."
|
||||||
|
)
|
||||||
|
|
||||||
|
# Posortuj tagi po czasie commita
|
||||||
|
sorted_tags = sort_tags_by_commit_time(merged_tags)
|
||||||
|
|
||||||
|
# Sprawdź czy HEAD jest otagowany
|
||||||
|
head_tags = sha_has_tag(base_head)
|
||||||
|
head_is_tagged = bool(head_tags)
|
||||||
|
|
||||||
|
# Utwórz orphan branch
|
||||||
|
logger.info("Tworzę sierocą gałąź: %s", args.new_branch)
|
||||||
|
checkout_orphan_branch(args.new_branch)
|
||||||
|
|
||||||
|
prev_sha: Optional[str] = None
|
||||||
|
last_tag_name: Optional[str] = None
|
||||||
|
|
||||||
|
# Dla każdego tagu – commit z jego zawartości
|
||||||
|
for tag_name, tag_sha, _ts in sorted_tags:
|
||||||
|
logger.info("Przetwarzam tag: %s (%s)", tag_name, tag_sha[:12])
|
||||||
|
replace_worktree_with_commit(tag_sha)
|
||||||
|
intermediates = list_intermediate_messages(prev_sha, tag_sha)
|
||||||
|
msg = build_commit_message_for_tag(tag_name, intermediates)
|
||||||
|
commit_all(msg)
|
||||||
|
prev_sha = tag_sha
|
||||||
|
last_tag_name = tag_name
|
||||||
|
|
||||||
|
# Jeśli HEAD nie jest dokładnie ostatnim tagiem – dorzuć "unreleased"
|
||||||
|
if not head_is_tagged:
|
||||||
|
logger.info("Dodaję końcowy commit z bieżącego HEAD (unreleased).")
|
||||||
|
replace_worktree_with_commit(base_head)
|
||||||
|
inter = list_intermediate_messages(prev_sha, base_head)
|
||||||
|
msg = build_commit_message_for_head(last_tag_name, inter)
|
||||||
|
commit_all(msg)
|
||||||
|
else:
|
||||||
|
logger.info("HEAD jest oznaczony tagiem – kończę na ostatnim tagu.")
|
||||||
|
|
||||||
|
# Push do nowego repo jeśli podano
|
||||||
|
if args.new_repo_url:
|
||||||
|
logger.info("Wypycham nową gałąź do: %s", args.new_repo_url)
|
||||||
|
push_new_branch(args.new_repo_url, args.new_branch)
|
||||||
|
|
||||||
|
logger.info("Zakończono pomyślnie.")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
except GitError as ge:
|
||||||
|
logger.error("Błąd gita: %s", ge)
|
||||||
|
return 2
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception("Nieoczekiwany błąd.") from e
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
+2
-2
@@ -18,8 +18,8 @@ from logging import handlers
|
|||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
from communication_subroutine import comm_subroutine
|
from conjurer.backup_old_docker.communication_subroutine import comm_subroutine
|
||||||
from constants import ENCODING, LOGFILE, TOKEN
|
from conjurer.backup_old_docker.constants import ENCODING, LOGFILE, TOKEN
|
||||||
logger = logging.getLogger("discord")
|
logger = logging.getLogger("discord")
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
handler = handlers.RotatingFileHandler(
|
handler = handlers.RotatingFileHandler(
|
||||||
|
|||||||
Reference in New Issue
Block a user