Skip to content

Text to vertical video in 100+ styles: AI codes each scene (HTML/SVG/WebGL), renders a 9:16 MP4 with music and English/Vietnamese voice. MCP, CLI and REST for AI agents.

Bộ cài một chạm Windows: LumReels-Setup.cmd + install.ps1 (winget, clone, npm install, shortcut), launcher start.cmd, uninstall.ps1

Lumtekac190eb99071
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..da5ccf8
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+*.cmd text eol=crlf
+*.ps1 text eol=crlf
diff --git a/README.md b/README.md
index 5b2c222..3abf975 100644
--- a/README.md
+++ b/README.md
@@ -43,7 +43,26 @@
<br><sub>Every style has been test-rendered with LumReels itself. Click to watch them with sound on <a href="https://reels.lumtek.net">reels.lumtek.net</a>.</sub>
</p>
-## Quick start
+## Install
+
+### Windows: one file, double-click
+
+1. Download [`LumReels-Setup.cmd`](https://raw.githubusercontent.com/lumtekvn/lumreels/main/install/windows/LumReels-Setup.cmd) (right-click, *Save link as…*) and double-click it.
+2. The installer checks for and installs what is missing through `winget`: **Node 22+**, **ffmpeg**, **Google Chrome**, **Git** (anything already there is skipped). It then fetches LumReels into `%LOCALAPPDATA%\LumReels\app`, runs `npm install`, adds a **LumReels** shortcut to the Desktop and Start Menu, and opens the app.
+3. On first launch the **System check** screen opens: paste an Anthropic key or sign in to Claude Code, then click **Make your first video**.
+
+Or paste one command into PowerShell:
+
+```powershell
+powershell -ExecutionPolicy Bypass -c "irm https://raw.githubusercontent.com/lumtekvn/lumreels/main/install/windows/install.ps1 | iex"
+```
+
+- No admin rights needed when a package has a per-user build (`winget --scope user`); Node and Chrome may ask for admin once.
+- Safe to re-run: an existing install only does `git pull` + `npm install`. Check only, install nothing: `LumReels-Setup.cmd -DryRun`.
+- Log: `%LOCALAPPDATA%\LumReels\install.log`. No `winget` on the machine: install **App Installer** from the Microsoft Store and run it again.
+- Uninstall: `powershell -ExecutionPolicy Bypass -File "%LOCALAPPDATA%\LumReels\app\install\windows\uninstall.ps1"`. Rendered videos move to `~/.lumreels/backup-…`; keys and voices in `~/.lumreels` stay unless you add `-Purge`.
+
+### Manual install (macOS, Linux, or by hand on Windows)
You need **Node 22+**, **ffmpeg** and **Google Chrome**.
diff --git a/README.vi.md b/README.vi.md
index 5640e50..30f4aff 100644
--- a/README.vi.md
+++ b/README.vi.md
@@ -43,7 +43,26 @@
<br><sub>Mẫu nào cũng đã dựng thử bằng chính LumReels. Bấm để xem video có tiếng trên <a href="https://reels.lumtek.net">reels.lumtek.net</a>.</sub>
</p>
-## Chạy thử trong 2 phút
+## Cài đặt
+
+### Windows: một file, bấm đúp
+
+1. Tải [`LumReels-Setup.cmd`](https://raw.githubusercontent.com/lumtekvn/lumreels/main/install/windows/LumReels-Setup.cmd) (chuột phải, *Lưu liên kết thành…*), bấm đúp.
+2. Bộ cài tự kiểm và cài thứ còn thiếu qua `winget`: **Node 22+**, **ffmpeg**, **Google Chrome**, **Git** (thứ đã có thì bỏ qua), tải LumReels vào `%LOCALAPPDATA%\LumReels\app`, chạy `npm install`, tạo shortcut **LumReels** ở Desktop và Start Menu rồi mở app.
+3. Lần đầu mở, màn **Kiểm tra máy** hiện ra: dán khoá Anthropic hoặc đăng nhập Claude Code, rồi bấm **Làm video đầu tiên**.
+
+Hoặc dán 1 lệnh vào PowerShell:
+
+```powershell
+powershell -ExecutionPolicy Bypass -c "irm https://raw.githubusercontent.com/lumtekvn/lumreels/main/install/windows/install.ps1 | iex"
+```
+
+- Không cần quyền admin khi gói có bản cho riêng người dùng (`winget --scope user`); Node và Chrome có thể hỏi quyền admin một lần.
+- Chạy lại an toàn: bản đã cài thì chỉ `git pull` + `npm install`. Chỉ kiểm, không cài gì: `LumReels-Setup.cmd -DryRun`.
+- Log: `%LOCALAPPDATA%\LumReels\install.log`. Máy chưa có `winget`: cài **App Installer** từ Microsoft Store rồi chạy lại.
+- Gỡ: `powershell -ExecutionPolicy Bypass -File "%LOCALAPPDATA%\LumReels\app\install\windows\uninstall.ps1"`. Video đã dựng được chuyển sang `~/.lumreels/backup-…`; khoá và giọng trong `~/.lumreels` giữ nguyên, thêm `-Purge` để xoá cả.
+
+### Cài thủ công (macOS, Linux, hoặc tự làm trên Windows)
Cần **Node 22+**, **ffmpeg** và **Google Chrome**.
diff --git a/install/windows/LumReels-Setup.cmd b/install/windows/LumReels-Setup.cmd
new file mode 100644
index 0000000..904870a
--- /dev/null
+++ b/install/windows/LumReels-Setup.cmd
@@ -0,0 +1,23 @@
+@echo off
+rem LumReels: bam dup file nay de cai LumReels tren Windows 10/11.
+rem Chay install.ps1 (cung thu muc) voi ExecutionPolicy Bypass chi cho tien trinh nay (khong doi cau hinh may).
+rem Khong co install.ps1 ben canh (chi tai rieng file .cmd) thi tai ban moi nhat tu GitHub.
+rem Tham so them truyen thang cho install.ps1, vd: LumReels-Setup.cmd -DryRun
+setlocal
+chcp 65001 >nul
+set "PS1=%~dp0install.ps1"
+if not exist "%PS1%" (
+ set "PS1=%TEMP%\lumreels-install.ps1"
+ powershell -NoProfile -ExecutionPolicy Bypass -Command "$ProgressPreference='SilentlyContinue'; Invoke-WebRequest -UseBasicParsing -Uri 'https://raw.githubusercontent.com/lumtekvn/lumreels/main/install/windows/install.ps1' -OutFile $env:TEMP\lumreels-install.ps1"
+ if errorlevel 1 (
+ echo.
+ echo [X] Khong tai duoc bo cai tu GitHub. Kiem tra mang roi bam dup lai.
+ pause
+ exit /b 1
+ )
+)
+powershell -NoProfile -ExecutionPolicy Bypass -File "%PS1%" %*
+set "CODE=%ERRORLEVEL%"
+echo.
+pause
+exit /b %CODE%
diff --git a/install/windows/install.ps1 b/install/windows/install.ps1
new file mode 100644
index 0000000..d787ddb
--- /dev/null
+++ b/install/windows/install.ps1
@@ -0,0 +1,328 @@
+# LumReels: bộ cài một chạm cho Windows 10/11.
+# Bấm đúp LumReels-Setup.cmd, hoặc trong PowerShell:
+# powershell -ExecutionPolicy Bypass -File install\windows\install.ps1 [-DryRun] [-NoLaunch]
+# powershell -ExecutionPolicy Bypass -c "irm https://raw.githubusercontent.com/lumtekvn/lumreels/main/install/windows/install.ps1 | iex"
+# Làm gì: kiểm rồi cài thiếu (qua winget) Node 22+, ffmpeg, Google Chrome, Git → clone/cập nhật mã vào
+# %LOCALAPPDATA%\LumReels\app → npm install → shortcut "LumReels" ở Desktop + Start Menu → mở app.
+# Chạy lại an toàn: thứ đã có thì bỏ qua, mã đã clone thì git pull.
+# -DryRun: chỉ kiểm và in việc sẽ làm, không cài, không tải, không tạo gì (trừ file log).
+# Log: %LOCALAPPDATA%\LumReels\install.log
+# File này phải lưu UTF-8 có BOM (Windows PowerShell 5.1 mới đọc đúng chữ có dấu).
+param(
+ [switch]$DryRun,
+ [switch]$NoLaunch,
+ [switch]$NoShortcut,
+ [string]$InstallDir = (Join-Path $env:LOCALAPPDATA 'LumReels\app'),
+ [string]$Repo = 'https://github.com/lumtekvn/lumreels.git',
+ [string]$Branch = ''
+)
+
+$ErrorActionPreference = 'Stop'
+$ProgressPreference = 'SilentlyContinue'
+try {
+ $utf8 = New-Object System.Text.UTF8Encoding $false
+ [Console]::OutputEncoding = $utf8
+ $OutputEncoding = $utf8
+} catch { }
+
+$BaseDir = Join-Path $env:LOCALAPPDATA 'LumReels'
+$LogFile = Join-Path $BaseDir 'install.log'
+$script:Failed = 0
+$script:Warned = 0
+$MIN_NODE = 22
+$MIN_FREE_GB = 3
+
+New-Item -ItemType Directory -Force -Path $BaseDir | Out-Null
+
+function Write-Log([string]$line) {
+ try { Add-Content -LiteralPath $LogFile -Value ("{0} {1}" -f (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'), $line) -Encoding UTF8 } catch { }
+}
+function Say([string]$kind, [string]$msg, [string]$hint = '') {
+ switch ($kind) {
+ 'ok' { Write-Host (' ✓ ' + $msg) -ForegroundColor Green }
+ 'fail' { Write-Host (' ✗ ' + $msg) -ForegroundColor Red; $script:Failed++ }
+ 'warn' { Write-Host (' ! ' + $msg) -ForegroundColor Yellow; $script:Warned++ }
+ 'plan' { Write-Host (' → ' + $msg) -ForegroundColor Cyan }
+ 'head' { Write-Host ''; Write-Host $msg -ForegroundColor White }
+ default { Write-Host (' ' + $msg) }
+ }
+ if ($hint) { Write-Host (' Cách sửa: ' + $hint) -ForegroundColor DarkGray }
+ Write-Log ("[{0}] {1}{2}" -f $kind, $msg, $(if ($hint) { ' | Cách sửa: ' + $hint } else { '' }))
+}
+
+function Update-SessionPath {
+ $machine = [Environment]::GetEnvironmentVariable('Path', 'Machine')
+ $user = [Environment]::GetEnvironmentVariable('Path', 'User')
+ $links = Join-Path $env:LOCALAPPDATA 'Microsoft\WinGet\Links'
+ $env:Path = (@($machine, $user, $links) | Where-Object { $_ }) -join ';'
+}
+
+function Find-Exe([string]$name) {
+ $c = Get-Command $name -ErrorAction SilentlyContinue | Select-Object -First 1
+ if ($c) { return $c.Source }
+ return $null
+}
+
+function Get-NodeMajor {
+ $exe = Find-Exe 'node'
+ if (-not $exe) { return $null }
+ try {
+ $v = (& $exe --version 2>$null | Select-Object -First 1)
+ if ($v -match '^v(\d+)\.') { return @{ major = [int]$Matches[1]; text = $v.Trim(); path = $exe } }
+ } catch { }
+ return $null
+}
+
+function Find-Chrome {
+ $cands = @(
+ $env:CHROME_PATH,
+ (Join-Path $env:ProgramFiles 'Google\Chrome\Application\chrome.exe'),
+ (Join-Path ${env:ProgramFiles(x86)} 'Google\Chrome\Application\chrome.exe'),
+ (Join-Path $env:LOCALAPPDATA 'Google\Chrome\Application\chrome.exe')
+ )
+ foreach ($c in $cands) { if ($c -and (Test-Path -LiteralPath $c)) { return $c } }
+ return $null
+}
+
+function Test-Winget { return [bool](Find-Exe 'winget') }
+
+# Cài 1 gói qua winget: thử --scope user trước (không cần quyền admin), không được thì cài bình thường (có thể hiện hộp UAC).
+function Install-WingetPackage([string]$id, [string]$label) {
+ $common = @('install', '--id', $id, '-e', '--silent', '--accept-package-agreements', '--accept-source-agreements', '--disable-interactivity')
+ Say 'info' ("Đang cài $label qua winget ($id)…")
+ Write-Log ("winget " + ($common -join ' ') + ' --scope user')
+ & winget @common --scope user 2>&1 | ForEach-Object { Write-Log (" winget: " + $_) }
+ $code = $LASTEXITCODE
+ if ($code -ne 0) {
+ Write-Log ("winget --scope user thoát mã $code, thử cài cho cả máy")
+ Say 'info' ("Bản cho riêng người dùng không có, cài cho cả máy (Windows có thể hỏi quyền admin, bấm Yes)…")
+ & winget @common 2>&1 | ForEach-Object { Write-Log (" winget: " + $_) }
+ $code = $LASTEXITCODE
+ }
+ Update-SessionPath
+ return $code
+}
+
+function Test-Online {
+ try {
+ $r = Invoke-WebRequest -Uri 'https://github.com' -Method Head -UseBasicParsing -TimeoutSec 8
+ return ($r.StatusCode -ge 200 -and $r.StatusCode -lt 400)
+ } catch { return $false }
+}
+
+function New-LumIcon([string]$file) {
+ if (Test-Path -LiteralPath $file) { return $true }
+ try {
+ Add-Type -AssemblyName System.Drawing
+ $bmp = New-Object System.Drawing.Bitmap 64, 64
+ $g = [System.Drawing.Graphics]::FromImage($bmp)
+ $g.SmoothingMode = 'AntiAlias'
+ $g.Clear([System.Drawing.Color]::FromArgb(255, 17, 17, 16))
+ $brush = New-Object System.Drawing.SolidBrush ([System.Drawing.Color]::FromArgb(255, 255, 107, 44))
+ $g.FillRectangle($brush, 22, 10, 20, 44)
+ $g.Dispose()
+ $icon = [System.Drawing.Icon]::FromHandle($bmp.GetHicon())
+ $fs = [System.IO.File]::Create($file)
+ $icon.Save($fs)
+ $fs.Close()
+ return $true
+ } catch { Write-Log ("tạo icon lỗi: " + $_.Exception.Message); return $false }
+}
+
+function New-Shortcut([string]$lnk, [string]$target, [string]$workDir, [string]$icon) {
+ $sh = New-Object -ComObject WScript.Shell
+ $s = $sh.CreateShortcut($lnk)
+ $s.TargetPath = $target
+ $s.WorkingDirectory = $workDir
+ $s.WindowStyle = 7
+ $s.Description = 'LumReels: dựng video dọc từ mẫu'
+ if ($icon -and (Test-Path -LiteralPath $icon)) { $s.IconLocation = $icon }
+ $s.Save()
+}
+
+function Invoke-Main {
+ Write-Log '================================================================'
+ Write-Log ("Bắt đầu cài LumReels{0}. InstallDir=$InstallDir" -f $(if ($DryRun) { ' (DryRun)' } else { '' }))
+ Write-Host ''
+ Write-Host 'LumReels: bộ cài cho Windows' -ForegroundColor White
+ if ($DryRun) { Write-Host '(chạy thử -DryRun: chỉ kiểm, không cài gì)' -ForegroundColor Cyan }
+ Write-Host ("Log: $LogFile") -ForegroundColor DarkGray
+
+ # ---- 1. Máy ----
+ Say 'head' '1. Kiểm máy'
+ $os = [Environment]::OSVersion.Version
+ if ($os.Major -ge 10) { Say 'ok' ("Windows $($os.Major).$($os.Minor) build $($os.Build)") }
+ else { Say 'fail' "Windows quá cũ ($os)" 'Cần Windows 10 hoặc 11.' }
+ Say 'ok' ("PowerShell $($PSVersionTable.PSVersion)")
+ if (-not [Environment]::Is64BitOperatingSystem) { Say 'fail' 'Windows 32-bit' 'LumReels cần Windows 64-bit.' }
+
+ $drive = (Split-Path -Qualifier $BaseDir)
+ try {
+ $disk = Get-CimInstance -ClassName Win32_LogicalDisk -Filter ("DeviceID='{0}'" -f $drive)
+ $freeGB = [math]::Round($disk.FreeSpace / 1GB, 1)
+ if ($freeGB -ge $MIN_FREE_GB) { Say 'ok' ("Ổ $drive còn trống $freeGB GB") }
+ else { Say 'fail' ("Ổ $drive chỉ còn $freeGB GB (cần ít nhất $MIN_FREE_GB GB)") 'Dọn bớt file, hoặc cài vào ổ khác: install.ps1 -InstallDir D:\LumReels\app' }
+ } catch { Say 'warn' 'Không đọc được dung lượng ổ đĩa' }
+
+ $online = Test-Online
+ if ($online) { Say 'ok' 'Có mạng, vào được GitHub' }
+ else { Say 'fail' 'Không vào được github.com' 'Kiểm tra mạng / proxy / VPN rồi chạy lại bộ cài.' }
+
+ $hasWinget = Test-Winget
+ if ($hasWinget) { Say 'ok' 'Có winget (trình cài gói của Windows)' }
+ else {
+ Say 'warn' 'Máy chưa có winget' 'Mở Microsoft Store, tìm "App Installer" (Trình cài đặt ứng dụng), bấm Cập nhật/Cài, rồi chạy lại bộ cài. Hoặc tự cài tay: Node 22+ (nodejs.org), ffmpeg (gyan.dev/ffmpeg), Chrome, Git (git-scm.com).'
+ }
+
+ # ---- 2. Phần mềm cần có ----
+ Say 'head' '2. Phần mềm cần có'
+ Update-SessionPath
+ $deps = @(
+ @{ key = 'node'; label = 'Node.js 22+'; id = 'OpenJS.NodeJS.LTS'; manual = 'Tải bản LTS ở https://nodejs.org rồi cài.' },
+ @{ key = 'ffmpeg'; label = 'ffmpeg'; id = 'Gyan.FFmpeg'; manual = 'Tải ở https://www.gyan.dev/ffmpeg/builds/ và thêm thư mục bin vào PATH.' },
+ @{ key = 'chrome'; label = 'Google Chrome'; id = 'Google.Chrome'; manual = 'Tải ở https://www.google.com/chrome/' },
+ @{ key = 'git'; label = 'Git'; id = 'Git.Git'; manual = 'Tải ở https://git-scm.com/download/win' }
+ )
+ foreach ($d in $deps) {
+ $found = $null; $detail = ''
+ switch ($d.key) {
+ 'node' { $n = Get-NodeMajor; if ($n -and $n.major -ge $MIN_NODE) { $found = $n.path; $detail = $n.text } elseif ($n) { $detail = "đang có $($n.text), cần v$MIN_NODE trở lên" } }
+ 'ffmpeg' { $found = Find-Exe 'ffmpeg' }
+ 'chrome' { $found = Find-Chrome }
+ 'git' { $found = Find-Exe 'git' }
+ }
+ if ($found) { Say 'ok' ("$($d.label): có ($(if ($detail) { $detail } else { $found }))"); continue }
+ $why = $(if ($detail) { " ($detail)" } else { '' })
+ if ($DryRun) {
+ if ($hasWinget) { Say 'plan' ("$($d.label): thiếu$why → sẽ cài: winget install --id $($d.id) -e --scope user") }
+ else { Say 'fail' ("$($d.label): thiếu$why") $d.manual }
+ continue
+ }
+ if (-not $hasWinget) { Say 'fail' ("$($d.label): thiếu$why") $d.manual; continue }
+ $code = Install-WingetPackage $d.id $d.label
+ $ok = $false
+ switch ($d.key) {
+ 'node' { $n = Get-NodeMajor; $ok = [bool]($n -and $n.major -ge $MIN_NODE) }
+ 'ffmpeg' { $ok = [bool](Find-Exe 'ffmpeg') }
+ 'chrome' { $ok = [bool](Find-Chrome) }
+ 'git' { $ok = [bool](Find-Exe 'git') }
+ }
+ if ($ok) { Say 'ok' ("$($d.label): đã cài") }
+ else { Say 'fail' ("$($d.label): cài không xong (winget mã $code)") ("Đóng cửa sổ này, mở lại LumReels-Setup.cmd (PATH mới chỉ có ở cửa sổ mới). Vẫn lỗi thì cài tay: " + $d.manual) }
+ }
+
+ $needCore = (-not (Find-Exe 'git')) -or (-not (Get-NodeMajor))
+ if ($needCore -and -not $DryRun) {
+ Say 'head' 'Dừng lại'
+ Say 'fail' 'Thiếu Node hoặc Git nên chưa lấy mã được' 'Sửa các mục ✗ ở trên rồi chạy lại bộ cài (chạy lại an toàn).'
+ return 1
+ }
+
+ # ---- 3. Mã LumReels ----
+ Say 'head' '3. Mã LumReels'
+ $isGit = Test-Path -LiteralPath (Join-Path $InstallDir '.git')
+ $isEmpty = -not (Test-Path -LiteralPath $InstallDir) -or -not (Get-ChildItem -LiteralPath $InstallDir -Force -ErrorAction SilentlyContinue | Select-Object -First 1)
+ if ($isGit) {
+ if ($DryRun) { Say 'plan' "Đã có ở $InstallDir → sẽ cập nhật: git pull --ff-only" }
+ else {
+ $out = & git -C $InstallDir pull --ff-only 2>&1
+ $out | ForEach-Object { Write-Log (" git: " + $_) }
+ if ($LASTEXITCODE -eq 0) { Say 'ok' "Đã cập nhật mã ở $InstallDir" }
+ else { Say 'warn' 'Không cập nhật được (máy có sửa tay hoặc mất mạng), dùng bản đang có' "Tự gộp: cd `"$InstallDir`"; git stash; git pull; git stash pop" }
+ }
+ } elseif ($isEmpty) {
+ if ($DryRun) { Say 'plan' "Sẽ tải mã: git clone $Repo `"$InstallDir`"" }
+ else {
+ New-Item -ItemType Directory -Force -Path (Split-Path -Parent $InstallDir) | Out-Null
+ $args2 = @('clone', '--quiet')
+ if ($Branch) { $args2 += @('--branch', $Branch) }
+ $args2 += @($Repo, $InstallDir)
+ $out = & git @args2 2>&1
+ $out | ForEach-Object { Write-Log (" git: " + $_) }
+ if ($LASTEXITCODE -eq 0) { Say 'ok' "Đã tải mã vào $InstallDir" }
+ else { Say 'fail' 'Tải mã từ GitHub lỗi' 'Kiểm tra mạng rồi chạy lại. Xem chi tiết trong install.log.'; return 1 }
+ }
+ } else {
+ Say 'fail' "Thư mục $InstallDir đã có file nhưng không phải bản clone git" 'Đổi tên/xoá thư mục đó, hoặc cài chỗ khác: install.ps1 -InstallDir <thư mục trống>'
+ if (-not $DryRun) { return 1 }
+ }
+
+ # ---- 4. Thư viện ----
+ Say 'head' '4. Thư viện (npm install)'
+ if ($DryRun) {
+ if (Test-Path -LiteralPath (Join-Path $InstallDir 'node_modules\hyperframes')) { Say 'plan' 'Đã có node_modules → sẽ chạy lại npm install (nhanh, chỉ bù phần thiếu)' }
+ else { Say 'plan' 'Sẽ chạy: npm install (tải khoảng 300 MB, 2–5 phút)' }
+ } else {
+ Push-Location $InstallDir
+ try {
+ Say 'info' 'Đang chạy npm install (lần đầu mất 2–5 phút)…'
+ $out = & npm.cmd install --no-audit --no-fund 2>&1
+ $code = $LASTEXITCODE
+ $out | ForEach-Object { Write-Log (" npm: " + $_) }
+ if ($code -eq 0) { Say 'ok' 'Đã cài thư viện + font tiếng Việt' }
+ else { Say 'fail' "npm install lỗi (mã $code)" "Xem install.log. Thử lại: cd `"$InstallDir`"; npm install" ; return 1 }
+ } finally { Pop-Location }
+ }
+
+ # ---- 5. Shortcut ----
+ Say 'head' '5. Shortcut'
+ $launcher = Join-Path $InstallDir 'install\windows\start.cmd'
+ if (-not $DryRun -and -not (Test-Path -LiteralPath $launcher)) {
+ # bản trên GitHub chưa có launcher (cũ hơn bộ cài này): chép launcher đi kèm bộ cài ra thư mục riêng
+ $own = $(if ($PSScriptRoot) { Join-Path $PSScriptRoot 'start.cmd' } else { $null })
+ if ($own -and (Test-Path -LiteralPath $own)) {
+ $ldir = Join-Path $BaseDir 'launcher'
+ New-Item -ItemType Directory -Force -Path $ldir | Out-Null
+ Copy-Item -LiteralPath $own, (Join-Path $PSScriptRoot 'start.ps1') -Destination $ldir -Force
+ $launcher = Join-Path $ldir 'start.cmd'
+ }
+ }
+ $icon = Join-Path $BaseDir 'lumreels.ico'
+ $desktop = [Environment]::GetFolderPath('Desktop')
+ $startMenu = Join-Path ([Environment]::GetFolderPath('Programs')) 'LumReels.lnk'
+ $desk = Join-Path $desktop 'LumReels.lnk'
+ if ($NoShortcut) { Say 'info' 'Bỏ qua shortcut (-NoShortcut)' }
+ elseif ($DryRun) {
+ foreach ($l in @($desk, $startMenu)) {
+ if (Test-Path -LiteralPath $l) { Say 'ok' "Đã có: $l (sẽ ghi lại cho đúng đích)" } else { Say 'plan' "Sẽ tạo: $l → $launcher" }
+ }
+ } elseif (-not (Test-Path -LiteralPath $launcher)) {
+ Say 'fail' 'Không thấy launcher start.cmd' 'Chạy tay: cd vào thư mục app rồi gõ npm start'
+ } else {
+ New-LumIcon $icon | Out-Null
+ try {
+ New-Shortcut $desk $launcher $InstallDir $icon
+ New-Shortcut $startMenu $launcher $InstallDir $icon
+ Say 'ok' 'Đã tạo shortcut "LumReels" ở Desktop và Start Menu'
+ } catch { Say 'warn' ('Tạo shortcut lỗi: ' + $_.Exception.Message) "Mở app bằng: `"$launcher`"" }
+ }
+
+ # ---- Tổng kết ----
+ Say 'head' 'Kết quả'
+ if ($DryRun) {
+ if ($script:Failed) { Say 'fail' "Có $($script:Failed) mục cần sửa tay trước khi cài (xem ✗ ở trên)" }
+ else { Say 'ok' 'Máy cài được. Chạy lại không có -DryRun để cài thật.' }
+ return [int]($script:Failed -gt 0)
+ }
+ if ($script:Failed) {
+ Say 'fail' "Cài xong nhưng còn $($script:Failed) mục lỗi (xem ✗ ở trên, chi tiết trong $LogFile)"
+ return 1
+ }
+ Say 'ok' 'Cài xong. Mở LumReels bằng shortcut "LumReels" trên Desktop.'
+ Write-Host ' Lần đầu mở, app hiện màn "Kiểm tra máy" để nhập khoá AI hoặc nối Claude Code.' -ForegroundColor DarkGray
+ if (-not $NoLaunch -and (Test-Path -LiteralPath $launcher)) {
+ Say 'info' 'Đang mở LumReels…'
+ Start-Process -FilePath $launcher -WorkingDirectory $InstallDir -WindowStyle Minimized
+ }
+ return 0
+}
+
+$code = 1
+try { $code = Invoke-Main }
+catch {
+ Say 'fail' ('Lỗi không lường trước: ' + $_.Exception.Message) "Gửi file $LogFile khi báo lỗi."
+ Write-Log ($_ | Out-String)
+}
+Write-Log ("Kết thúc, mã $code")
+# chạy qua `irm | iex` thì không exit (sẽ đóng luôn cửa sổ PowerShell của người dùng)
+if ($PSCommandPath) { exit $code }
diff --git a/install/windows/start.cmd b/install/windows/start.cmd
new file mode 100644
index 0000000..b40e94c
--- /dev/null
+++ b/install/windows/start.cmd
@@ -0,0 +1,3 @@
+@echo off
+rem Launcher LumReels: bat server an cua so (neu chua chay), doi cong 4400, mo trinh duyet. Logic o start.ps1.
+powershell -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File "%~dp0start.ps1" %*
diff --git a/install/windows/start.ps1 b/install/windows/start.ps1
new file mode 100644
index 0000000..8cd0efc
--- /dev/null
+++ b/install/windows/start.ps1
@@ -0,0 +1,65 @@
+# Launcher LumReels (start.cmd gọi file này, cửa sổ ẩn):
+# server đã chạy ở cổng 4400 → mở trình duyệt luôn;
+# chưa chạy → bật `node server/server.mjs` ẩn cửa sổ, đợi cổng 4400 (tối đa 90 giây), rồi mở trình duyệt.
+# Log server: %LOCALAPPDATA%\LumReels\server.log (+ server.err.log). Lỗi → hộp thông báo kèm đường dẫn log.
+# File này phải lưu UTF-8 có BOM (Windows PowerShell 5.1 mới đọc đúng chữ có dấu).
+param([string]$AppDir = '', [int]$Port = 4400, [switch]$NoBrowser)
+
+$ErrorActionPreference = 'Stop'
+$ProgressPreference = 'SilentlyContinue'
+$BaseDir = Join-Path $env:LOCALAPPDATA 'LumReels'
+New-Item -ItemType Directory -Force -Path $BaseDir | Out-Null
+$Url = "http://127.0.0.1:$Port/"
+
+function Show-Error([string]$msg) {
+ try { (New-Object -ComObject WScript.Shell).Popup($msg, 0, 'LumReels', 16) | Out-Null } catch { Write-Host $msg }
+}
+function Test-LumReels {
+ try {
+ $r = Invoke-WebRequest -Uri ($Url + 'api/version') -UseBasicParsing -TimeoutSec 2
+ return ($r.StatusCode -eq 200 -and $r.Content -match '"version"')
+ } catch { return $false }
+}
+function Test-PortBusy {
+ $c = New-Object System.Net.Sockets.TcpClient
+ try { $iar = $c.BeginConnect('127.0.0.1', $Port, $null, $null); $ok = $iar.AsyncWaitHandle.WaitOne(400); if ($ok) { $c.EndConnect($iar) }; return $ok -and $c.Connected }
+ catch { return $false } finally { $c.Close() }
+}
+
+if (-not $AppDir) {
+ $here = Resolve-Path (Join-Path $PSScriptRoot '..\..') -ErrorAction SilentlyContinue
+ if ($here -and (Test-Path -LiteralPath (Join-Path $here 'server\server.mjs'))) { $AppDir = $here.Path }
+ else { $AppDir = Join-Path $BaseDir 'app' }
+}
+if (-not (Test-Path -LiteralPath (Join-Path $AppDir 'server\server.mjs'))) {
+ Show-Error "Không thấy LumReels ở $AppDir.`nChạy lại bộ cài LumReels-Setup.cmd."
+ exit 1
+}
+
+if (-not (Test-LumReels)) {
+ if (Test-PortBusy) {
+ Show-Error "Cổng $Port đang bị chương trình khác dùng, LumReels không bật được.`nTắt chương trình đó, hoặc khởi động lại máy rồi mở lại LumReels."
+ exit 1
+ }
+ $machine = [Environment]::GetEnvironmentVariable('Path', 'Machine')
+ $user = [Environment]::GetEnvironmentVariable('Path', 'User')
+ $env:Path = (@($machine, $user, (Join-Path $env:LOCALAPPDATA 'Microsoft\WinGet\Links')) | Where-Object { $_ }) -join ';'
+ $node = Get-Command node -ErrorAction SilentlyContinue | Select-Object -First 1
+ if (-not $node) { Show-Error "Máy chưa có Node.js.`nChạy lại bộ cài LumReels-Setup.cmd."; exit 1 }
+ $env:PORT = "$Port"
+ $log = Join-Path $BaseDir 'server.log'
+ $err = Join-Path $BaseDir 'server.err.log'
+ $proc = Start-Process -FilePath $node.Source -ArgumentList 'server/server.mjs' -WorkingDirectory $AppDir -WindowStyle Hidden `
+ -RedirectStandardOutput $log -RedirectStandardError $err -PassThru
+ Set-Content -LiteralPath (Join-Path $BaseDir 'server.pid') -Value $proc.Id -Encoding ASCII
+ $deadline = (Get-Date).AddSeconds(90)
+ while (-not (Test-LumReels)) {
+ if ((Get-Date) -gt $deadline) {
+ Show-Error "LumReels chưa bật được sau 90 giây.`nXem lỗi trong:`n$err"
+ exit 1
+ }
+ Start-Sleep -Milliseconds 500
+ }
+}
+if (-not $NoBrowser) { Start-Process $Url }
+exit 0
diff --git a/install/windows/uninstall.ps1 b/install/windows/uninstall.ps1
new file mode 100644
index 0000000..868cf01
--- /dev/null
+++ b/install/windows/uninstall.ps1
@@ -0,0 +1,92 @@
+# Gỡ LumReels khỏi Windows.
+# powershell -ExecutionPolicy Bypass -File install\windows\uninstall.ps1 [-Purge] [-Yes] [-DryRun]
+# Xoá: %LOCALAPPDATA%\LumReels (mã app, launcher, log) + shortcut Desktop/Start Menu; tắt server LumReels đang chạy từ đó.
+# GIỮ LẠI (trừ khi -Purge): ~/.lumreels (khoá AI đã nhập, giọng của tôi, gói mẫu, nháp)
+# và video đã dựng: jobs/, edits/ trong thư mục app được chuyển sang ~/.lumreels/backup-<ngày giờ>/ trước khi xoá.
+# -Purge: xoá luôn ~/.lumreels và không giữ video đã dựng.
+# Không gỡ Node, ffmpeg, Chrome, Git (máy có thể đang dùng cho việc khác): gỡ trong Settings > Apps nếu muốn.
+# File này phải lưu UTF-8 có BOM (Windows PowerShell 5.1 mới đọc đúng chữ có dấu).
+param([switch]$Purge, [switch]$Yes, [switch]$DryRun)
+
+$ErrorActionPreference = 'Stop'
+try { $utf8 = New-Object System.Text.UTF8Encoding $false; [Console]::OutputEncoding = $utf8; $OutputEncoding = $utf8 } catch { }
+
+$BaseDir = Join-Path $env:LOCALAPPDATA 'LumReels'
+$AppDir = Join-Path $BaseDir 'app'
+$UserData = $(if ($env:LUMREELS_HOME) { $env:LUMREELS_HOME } else { Join-Path $HOME '.lumreels' })
+$links = @((Join-Path ([Environment]::GetFolderPath('Desktop')) 'LumReels.lnk'), (Join-Path ([Environment]::GetFolderPath('Programs')) 'LumReels.lnk'))
+
+function Say([string]$kind, [string]$msg) {
+ switch ($kind) {
+ 'ok' { Write-Host (' ✓ ' + $msg) -ForegroundColor Green }
+ 'fail' { Write-Host (' ✗ ' + $msg) -ForegroundColor Red }
+ 'plan' { Write-Host (' → ' + $msg) -ForegroundColor Cyan }
+ default { Write-Host (' ' + $msg) }
+ }
+}
+
+Write-Host ''
+Write-Host 'Gỡ LumReels' -ForegroundColor White
+if ($DryRun) { Write-Host '(chạy thử -DryRun: không xoá gì)' -ForegroundColor Cyan }
+Write-Host (" Sẽ xoá: $BaseDir và shortcut LumReels")
+if ($Purge) { Write-Host (" -Purge: xoá luôn dữ liệu người dùng $UserData và video đã dựng") -ForegroundColor Yellow }
+else { Write-Host (" Giữ lại: $UserData (khoá AI, giọng, gói mẫu) + video đã dựng") }
+
+if (-not $Yes -and -not $DryRun) {
+ $a = Read-Host ' Gõ Y rồi Enter để gỡ'
+ if ($a -notmatch '^\s*[yY]') { Say 'info' 'Đã huỷ, không xoá gì.'; if ($PSCommandPath) { exit 0 } else { return } }
+}
+
+# 1. tắt server LumReels do launcher bật (PID ghi ở server.pid), chỉ khi đúng là node chạy server/server.mjs
+$procs = @()
+$pidFile = Join-Path $BaseDir 'server.pid'
+if (Test-Path -LiteralPath $pidFile) {
+ try {
+ $id = [int](Get-Content -LiteralPath $pidFile -TotalCount 1)
+ $procs = @(Get-CimInstance Win32_Process -Filter "ProcessId=$id" | Where-Object { $_.Name -eq 'node.exe' -and $_.CommandLine -match 'server[\/]server\.mjs' })
+ } catch { }
+}
+foreach ($p in $procs) {
+ if ($DryRun) { Say 'plan' "Sẽ tắt server LumReels (PID $($p.ProcessId))" }
+ else { try { Stop-Process -Id $p.ProcessId -Force; Start-Sleep -Milliseconds 500; Say 'ok' "Đã tắt server LumReels (PID $($p.ProcessId))" } catch { Say 'fail' "Không tắt được PID $($p.ProcessId): $($_.Exception.Message)" } }
+}
+
+# 2. giữ video đã dựng
+if (-not $Purge -and (Test-Path -LiteralPath $AppDir)) {
+ $keep = @('jobs', 'edits') | ForEach-Object { Join-Path $AppDir $_ } | Where-Object { (Test-Path -LiteralPath $_) -and (Get-ChildItem -LiteralPath $_ -Force | Select-Object -First 1) }
+ if ($keep) {
+ $bk = Join-Path $UserData ('backup-' + (Get-Date -Format 'yyyyMMdd-HHmmss'))
+ foreach ($k in $keep) {
+ if ($DryRun) { Say 'plan' "Sẽ chuyển $k → $bk" }
+ else {
+ New-Item -ItemType Directory -Force -Path $bk | Out-Null
+ Move-Item -LiteralPath $k -Destination $bk
+ Say 'ok' "Đã giữ $(Split-Path -Leaf $k) ở $bk"
+ }
+ }
+ }
+}
+
+# 3. shortcut + thư mục app
+foreach ($l in $links) {
+ if (Test-Path -LiteralPath $l) {
+ if ($DryRun) { Say 'plan' "Sẽ xoá $l" } else { Remove-Item -LiteralPath $l -Force; Say 'ok' "Đã xoá $l" }
+ }
+}
+if (Test-Path -LiteralPath $BaseDir) {
+ if ($DryRun) { Say 'plan' "Sẽ xoá $BaseDir" }
+ else {
+ try { Remove-Item -LiteralPath $BaseDir -Recurse -Force; Say 'ok' "Đã xoá $BaseDir" }
+ catch { Say 'fail' ("Chưa xoá hết $BaseDir (" + $_.Exception.Message + '). Tắt LumReels/trình duyệt đang mở file trong đó rồi chạy lại.') }
+ }
+} else { Say 'ok' 'Không còn thư mục app' }
+
+# 4. dữ liệu người dùng
+if ($Purge -and (Test-Path -LiteralPath $UserData)) {
+ if ($DryRun) { Say 'plan' "Sẽ xoá $UserData" }
+ else { Remove-Item -LiteralPath $UserData -Recurse -Force; Say 'ok' "Đã xoá $UserData" }
+}
+
+Write-Host ''
+Say 'info' 'Node, ffmpeg, Chrome, Git vẫn giữ nguyên. Gỡ trong Settings > Apps nếu không dùng nữa.'
+if ($PSCommandPath) { exit 0 }