feat(run): abre o Java da placa real e guarda dados no clone

Linux, WSL e Windows usam o mesmo run --all, e plugins, cache e logs ficam em .pitiupi na raiz do projeto.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Gabriel Felipe Souza SantosandCursor committed 2026-11-03 23:52:08 -03:00
1 parent 22540eaffb
commit e84aba2f4e
15 files changed
+328 -68

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
@echo off
setlocal EnableExtensions
cd /d "%~dp0.."
if /I "%~1"=="run" goto run
echo Uso: scripts\pitiupi.cmd run --all
exit /b 1
:run
where ant >nul 2>&1
if errorlevel 1 (
echo ERRO: ant nao esta no PATH. Instale o Apache Ant e o JDK 17.
exit /b 1
)
where javac >nul 2>&1
if errorlevel 1 (
echo ERRO: javac nao esta no PATH. Instale o JDK 17.
exit /b 1
)
call ant -f "%CD%\pitiupi\build.xml" jar
if errorlevel 1 exit /b 1
if not exist "%CD%\.pitiupi\plugins" mkdir "%CD%\.pitiupi\plugins"
del /q "%CD%\.pitiupi\plugins\*.jar" 2>nul
set "PITIUPI_REPO=%CD%"
set "PITIUPI_PLUGINS=%CD%\.pitiupi\plugins"
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "$repo = $env:PITIUPI_REPO; $dest = $env:PITIUPI_PLUGINS; $reg = Get-Content -Raw (Join-Path $repo 'plugins.registry.json') | ConvertFrom-Json; foreach ($p in $reg.plugins) { $dir = Join-Path $repo ($p.dir -replace '/','\'); if ($p.build -ne 'ant') { Write-Error ('build nao suportado neste prompt: ' + $p.build); exit 1 }; & ant -f (Join-Path $dir 'build.xml') jar; if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }; $src = Join-Path $dir ($p.jar -replace '/','\'); if (-not (Test-Path -LiteralPath $src)) { Write-Error ('JAR ausente: ' + $src); exit 1 }; Copy-Item -LiteralPath $src -Destination (Join-Path $dest ($p.id + '.jar')) -Force }"
if errorlevel 1 exit /b 1
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0run-windows.ps1" -PitiupiHome "%CD%\.pitiupi" -Jar "%CD%\pitiupi\dist\pitiupi.jar"
if errorlevel 1 exit /b 1
echo Janela aberta no Windows. Cabo e Wi-Fi sao as placas desta maquina.
echo Plugins em %CD%\.pitiupi\plugins
exit /b 0
+61 -7
View File
@@ -4,7 +4,7 @@ set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
CORE="${REPO_ROOT}/pitiupi"
PITIUPI_HOME="${PITIUPI_HOME:-$HOME/pitiupi}"
PITIUPI_HOME="${PITIUPI_HOME:-${REPO_ROOT}/.pitiupi}"
PLUGINS_DIR="${PITIUPI_HOME}/plugins"
REGISTRY="${REPO_ROOT}/plugins.registry.json"
export PITIUPI_HOME
@@ -31,6 +31,10 @@ Exemplos:
./scripts/pitiupi.sh run --all
./scripts/pitiupi.sh run --category Social
./scripts/pitiupi.sh run --plugins chat
Linux: no terminal, ./scripts/pitiupi.sh run --all (Java do Linux).
WSL: no terminal do Ubuntu, o mesmo comando (a janela abre no Java do Windows).
Windows: no cmd, scripts\pitiupi.cmd run --all (Java do Windows).
EOF
}
@@ -196,7 +200,27 @@ build_plugins_from_selection() {
done < <(selected_ids)
}
running_on_wsl() {
[[ -r /proc/version ]] && grep -qi microsoft /proc/version
}
running_on_git_bash() {
[[ "${OSTYPE:-}" == msys* || "${OSTYPE:-}" == mingw* ]]
}
to_windows_path() {
if running_on_wsl && command -v wslpath >/dev/null 2>&1; then
wslpath -w "$1"
elif command -v cygpath >/dev/null 2>&1; then
cygpath -w "$1"
else
printf 'ERRO: não sei converter o caminho para o Windows: %s\n' "$1" >&2
exit 1
fi
}
link_plugins_from_selection() {
local mode="${1:-link}"
local id dir jar_rel link_name src_abs
mkdir -p "${PLUGINS_DIR}"
rm -f "${PLUGINS_DIR}/"*.jar
@@ -207,7 +231,15 @@ link_plugins_from_selection() {
jar_rel="$(registry_python field "$id" jar)"
link_name="${id}.jar"
src_abs="${REPO_ROOT}/${dir}/${jar_rel}"
ln -sf "${src_abs}" "${PLUGINS_DIR}/${link_name}"
if [[ ! -f "${src_abs}" ]]; then
printf 'ERRO: JAR ausente: %s\n' "${src_abs}" >&2
exit 1
fi
if [[ "${mode}" == "copy" ]]; then
cp -L "${src_abs}" "${PLUGINS_DIR}/${link_name}"
else
ln -sf "${src_abs}" "${PLUGINS_DIR}/${link_name}"
fi
done < <(selected_ids)
local count
@@ -217,12 +249,27 @@ link_plugins_from_selection() {
else
printf 'Plugins ativos em %s:\n' "${PLUGINS_DIR}"
ls -1 "${PLUGINS_DIR}"/*.jar
for jar in "${PLUGINS_DIR}"/*.jar; do
[[ -L "$jar" ]] && printf ' -> %s\n' "$(readlink -f "$jar")"
done
if [[ "${mode}" != "copy" ]]; then
local jar
for jar in "${PLUGINS_DIR}"/*.jar; do
[[ -L "$jar" ]] && printf ' -> %s\n' "$(readlink -f "$jar")"
done
fi
fi
}
launch_windows_java() {
local home_win jar_win ps1
if ! command -v powershell.exe >/dev/null 2>&1; then
printf 'ERRO: o PowerShell do Windows não está no PATH.\n' >&2
exit 1
fi
home_win="$(to_windows_path "${PITIUPI_HOME}")"
jar_win="$(to_windows_path "${CORE}/dist/pitiupi.jar")"
ps1="$(to_windows_path "${REPO_ROOT}/scripts/run-windows.ps1")"
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "${ps1}" -PitiupiHome "${home_win}" -Jar "${jar_win}"
}
check_tools() {
local ok=0
for cmd in java javac ant make python3; do
@@ -323,7 +370,14 @@ case "${CMD}" in
check_tools || exit 1
build_core
build_plugins_from_selection
link_plugins_from_selection
exec java -jar "${CORE}/dist/pitiupi.jar"
if running_on_wsl || running_on_git_bash; then
link_plugins_from_selection copy
launch_windows_java
printf 'Janela aberta no Windows. Cabo e Wi-Fi são as placas desta máquina.\n'
printf 'Plugins em %s\n' "${PLUGINS_DIR}"
else
link_plugins_from_selection link
exec java -jar "${CORE}/dist/pitiupi.jar"
fi
;;
esac
+48
View File
@@ -0,0 +1,48 @@
# Chamado por scripts/pitiupi.sh (WSL ou Git Bash) e por scripts/pitiupi.cmd.
# Não copia plugins: quem chama já deixou o JAR e o PITIUPI_HOME prontos.
param(
[Parameter(Mandatory = $true)][string]$PitiupiHome,
[Parameter(Mandatory = $true)][string]$Jar
)
$ErrorActionPreference = 'Stop'
function Find-JavaExe {
$cmd = Get-Command java -ErrorAction SilentlyContinue
if ($cmd -and $cmd.Source -notmatch '\\WindowsApps\\') {
return $cmd.Source
}
$patterns = @(
(Join-Path $env:ProgramFiles 'Microsoft\jdk-*\bin\java.exe'),
(Join-Path $env:ProgramFiles 'Eclipse Adoptium\jdk-*\bin\java.exe'),
(Join-Path $env:ProgramFiles 'Java\jdk-*\bin\java.exe'),
(Join-Path ${env:ProgramFiles(x86)} 'Microsoft\jdk-*\bin\java.exe'),
(Join-Path $env:LOCALAPPDATA 'Programs\Microsoft\jdk-*\bin\java.exe')
)
foreach ($pat in $patterns) {
$hit = Get-Item -Path $pat -ErrorAction SilentlyContinue |
Sort-Object FullName -Descending |
Select-Object -First 1
if ($hit) { return $hit.FullName }
}
return $null
}
if (-not (Test-Path -LiteralPath $Jar)) {
Write-Error "JAR ausente: $Jar"
}
if (-not (Test-Path -LiteralPath $PitiupiHome)) {
Write-Error "PITIUPI_HOME ausente: $PitiupiHome"
}
$javaExe = Find-JavaExe
if (-not $javaExe) {
Write-Error "Java do Windows nao encontrado. No PowerShell: winget install Microsoft.OpenJDK.17 --accept-package-agreements"
}
Get-CimInstance Win32_Process -Filter "Name = 'java.exe' OR Name = 'javaw.exe'" -ErrorAction SilentlyContinue |
Where-Object { $_.CommandLine -and $_.CommandLine -like '*pitiupi.jar*' } |
ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }
$env:PITIUPI_HOME = $PitiupiHome
Start-Process -FilePath $javaExe -ArgumentList @('-jar', $Jar)