AI media harness for planning, generating, and editing locally
TypeScript
Use bundled SlopFab runtime
Bitti43df6d1e4c1c
diff --git a/README.md b/README.mdindex ea226e7..4836ae4 100644--- a/README.md+++ b/README.md@@ -15,6 +15,12 @@ For the native desktop shell, install the [Tauri prerequisites](https://v2.taurinpm run tauri dev```+The Windows x64 SlopFab runtime is included as [slopfab.dll](lib/slopfab/slopfab.dll)+through Git LFS. Run `git lfs pull` after cloning. Development builds, installers,+and portable packages place this DLL beside `Slopus.exe`; no external SlopFab+checkout is needed. Model weights and GPU drivers/toolkits remain separate.+Only `slopfab.dll` is bundled; Slopus does not require FFmpeg or companion files.+Tests and production validation:```sh@@ -86,6 +92,12 @@ icon already rendering finish. Manual icon generation remains available.`npm run reference-icons` renders every missing character, product, location, and style preset with MiniMax H3 at 768×768 and 20 steps. Its DLL backend uses the dedicated still-image mode, downsamples each 3×3 pixel block to produce a 256×256 icon, and encodes it at JPEG quality 95 without creating an intermediate video or audio file. Character entries use controlled headshot lighting; product and location entries use a complete-subject view; style entries use a representative composition with lighting and rendering tailored to the named style.-SlopFab, Cargo, and FFmpeg must be installed. The script uses the development paths under `D:\Projects\slopfab` by default; `SLOPFAB_EXE`, `SLOPFAB_TRANSFORMER`, `SLOPFAB_TEXT_ENCODER`, `SLOPFAB_VIDEO_VAE`, `SLOPFAB_AUDIO_VAE`, `SLOPFAB_BACKEND`, `CARGO_EXE`, and `FFMPEG_EXE` can override them. Use `node scripts/generate-reference-icons.mjs --id=<preset-id> --force` to regenerate one entry.+The reference icon batch uses the vendored `lib/slopfab/slopfab.dll` and requires+Cargo and model weights. `SLOPFAB_DLL` can explicitly override the runtime;+`SLOPFAB_TRANSFORMER`, `SLOPFAB_TEXT_ENCODER`, `SLOPFAB_VIDEO_VAE`,+`SLOPFAB_AUDIO_VAE`, `SLOPFAB_BACKEND`, and `CARGO_EXE` override the other settings.+Model paths still default to the development weights under `D:\Projects\slopfab`.+The optional `--dry-run` CLI path requires `slopfab` on PATH or `SLOPFAB_EXE`.+Use `node scripts/generate-reference-icons.mjs --id=<preset-id> --force` to regenerate one entry.The batch defaults to two GPU workers. Set `REFERENCE_ICON_WORKERS=1` or pass `--workers=1` on a lower-memory card. Use `--type=style` to generate or replace only style icons; `--shard=1/2` selects the first alternating half for a resumable recovery pass.diff --git a/package.cmd b/package.cmdindex 5767da9..16e9893 100644--- a/package.cmd+++ b/package.cmd@@ -7,10 +7,7 @@ set "ROOT_DIR=%CD%"set "ARTIFACTS_DIR=%ROOT_DIR%\artifacts"set "RELEASE_EXE=%ROOT_DIR%\src-tauri\target\release\slopus.exe"-rem The generation runtime is built by a separate project. Override with-rem set SLOPFAB_DIR=...\build\Release-rem before running if it lives somewhere else.-if not defined SLOPFAB_DIR set "SLOPFAB_DIR=D:\Projects\slopfab\build\Release"+set "SLOPFAB_DIR=%ROOT_DIR%\lib\slopfab"where.exe npm.cmd >nul 2>nul || (echo ERROR: npm was not found on PATH.@@ -101,19 +98,9 @@ mkdir "%OUTPUT_DIR%" || goto :failcopy /Y "%RELEASE_EXE%" "%OUTPUT_DIR%\Slopus.exe" >nul || goto :fail> "%OUTPUT_DIR%\slopus-portable" echo Portable distribution - update by downloading a new portable ZIP.-set "SLOPFAB_BUNDLED=no"-if exist "%SLOPFAB_DIR%\slopfab.dll" (- rem Beside Slopus.exe, not in a subfolder. That is where the app looks,- rem so there is nothing left for anyone to configure - and slopfab.dll is- rem loaded with LOAD_WITH_ALTERED_SEARCH_PATH, so its dependencies have to- rem sit in the same folder as it anyway.- copy /Y "%SLOPFAB_DIR%\slopfab.dll" "%OUTPUT_DIR%\" >nul || goto :fail- set "SLOPFAB_BUNDLED=yes"- echo Runtime: slopfab.dll included.-) else (- echo Runtime: slopfab not found at %SLOPFAB_DIR% - shipping without it.- echo The app still runs; it reports the generator as unavailable.-)+rem Match the installer's resource layout: one DLL beside Slopus.exe.+copy /Y "%SLOPFAB_DIR%\slopfab.dll" "%OUTPUT_DIR%\slopfab.dll" >nul || goto :fail+echo Runtime: slopfab.dll included.call :write_readme "%OUTPUT_DIR%\README.txt"echo Folder: %OUTPUT_STEM%-portable\@@ -146,11 +133,7 @@ exit /b 0>>"%~1" echo Microsoft Edge WebView2. Use the setup installer if it is missing.>>"%~1" echo.>>"%~1" echo VIDEO GENERATION-if /I "%SLOPFAB_BUNDLED%"=="yes" (- >>"%~1" echo The runtime is included. Keep slopfab.dll beside Slopus.exe.-) else (- >>"%~1" echo The runtime is not included. Editing still works.-)+>>"%~1" echo The runtime is included. Keep slopfab.dll beside Slopus.exe.>>"%~1" echo Model weights are not included. Set their paths in Settings.exit /b 0diff --git a/release.cmd b/release.cmdindex 2ec2593..998c2ef 100644--- a/release.cmd+++ b/release.cmd@@ -18,10 +18,7 @@ if not defined TAURI_SIGNING_PRIVATE_KEY ()node scripts\updater-manifest.mjs --check || goto :fail-rem The generation runtime is built by a separate project. Override with-rem set SLOPFAB_DIR=...\build\Release-rem before running if it lives somewhere else.-if not defined SLOPFAB_DIR set "SLOPFAB_DIR=D:\Projects\slopfab\build\Release"+set "SLOPFAB_DIR=%ROOT_DIR%\lib\slopfab"where.exe npm.cmd >nul 2>nul || (echo ERROR: npm was not found on PATH.@@ -139,19 +136,9 @@ mkdir "%OUTPUT_DIR%" || goto :failcopy /Y "%RELEASE_EXE%" "%OUTPUT_DIR%\Slopus.exe" >nul || goto :fail> "%OUTPUT_DIR%\slopus-portable" echo Portable distribution - update by downloading a new portable ZIP.-set "SLOPFAB_BUNDLED=no"-if exist "%SLOPFAB_DIR%\slopfab.dll" (- rem Beside Slopus.exe, not in a subfolder. That is where the app looks,- rem so there is nothing left for anyone to configure - and slopfab.dll is- rem loaded with LOAD_WITH_ALTERED_SEARCH_PATH, so its dependencies have to- rem sit in the same folder as it anyway.- copy /Y "%SLOPFAB_DIR%\slopfab.dll" "%OUTPUT_DIR%\" >nul || goto :fail- set "SLOPFAB_BUNDLED=yes"- echo Runtime: slopfab.dll included.-) else (- echo Runtime: slopfab not found at %SLOPFAB_DIR% - shipping without it.- echo The app still runs; it reports the generator as unavailable.-)+rem Match the installer's resource layout: one DLL beside Slopus.exe.+copy /Y "%SLOPFAB_DIR%\slopfab.dll" "%OUTPUT_DIR%\slopfab.dll" >nul || goto :fail+echo Runtime: slopfab.dll included.call :write_readme "%OUTPUT_DIR%\README.txt"echo Folder: %OUTPUT_STEM%-portable\@@ -189,11 +176,7 @@ exit /b 0>>"%~1" echo Microsoft Edge WebView2. Use the setup installer if it is missing.>>"%~1" echo.>>"%~1" echo VIDEO GENERATION-if /I "%SLOPFAB_BUNDLED%"=="yes" (- >>"%~1" echo The runtime is included. Keep slopfab.dll beside Slopus.exe.-) else (- >>"%~1" echo The runtime is not included. Editing still works.-)+>>"%~1" echo The runtime is included. Keep slopfab.dll beside Slopus.exe.>>"%~1" echo Model weights are not included. Set their paths in Settings.exit /b 0diff --git a/scripts/generate-reference-icons.mjs b/scripts/generate-reference-icons.mjsindex 3fb1ff3..f9058fe 100644--- a/scripts/generate-reference-icons.mjs+++ b/scripts/generate-reference-icons.mjs@@ -10,7 +10,8 @@ const repository = resolve(scriptDirectory, "..");const outputDirectory = join(repository, "src", "assets", "reference-icons");const defaults = {- executable: "D:\\Projects\\slopfab\\build\\Release\\slopfab.exe",+ executable: "slopfab",+ dll: join(repository, "lib", "slopfab", "slopfab.dll"),transformer: "D:\\Projects\\slopfab\\weights\\transformer\\MiniMax_H3_FL2VA_pruned_nvfp4.safetensors",textEncoder: "D:\\Projects\\slopfab\\weights\\text_encoder\\qwen3vl_32b_minimax_h3_nvfp4_awq.safetensors",videoVae: "D:\\Projects\\slopfab\\weights\\vae\\video_vae_nf4.safetensors",@@ -20,12 +21,12 @@ const defaults = {const settings = {executable: process.env.SLOPFAB_EXE || defaults.executable,+ dll: process.env.SLOPFAB_DLL || defaults.dll,transformer: process.env.SLOPFAB_TRANSFORMER || defaults.transformer,textEncoder: process.env.SLOPFAB_TEXT_ENCODER || defaults.textEncoder,videoVae: process.env.SLOPFAB_VIDEO_VAE || defaults.videoVae,audioVae: process.env.SLOPFAB_AUDIO_VAE || defaults.audioVae,cargo: process.env.CARGO_EXE || defaults.cargo,- ffmpeg: process.env.FFMPEG_EXE || "ffmpeg",};const force = process.argv.includes("--force");@@ -47,20 +48,6 @@ function run(command, args, options = {}) {});}-function runQuiet(command, args, options = {}) {- return new Promise((accept, reject) => {- const child = spawn(command, args, { stdio: ["ignore", "pipe", "pipe"], windowsHide: true, ...options });- let output = "";- child.stdout.on("data", (chunk) => { output = `${output}${chunk}`.slice(-12_000); });- child.stderr.on("data", (chunk) => { output = `${output}${chunk}`.slice(-12_000); });- child.once("error", reject);- child.once("exit", (code, signal) => {- if (code === 0) accept();- else reject(new Error(`${command} stopped with ${signal ? `signal ${signal}` : `exit code ${code}`}.\n${output}`));- });- });-}-function loadCatalog() {const runner = join(repository, "node_modules", "vite-node", "vite-node.mjs");const helper = join(scriptDirectory, "reference-icon-catalog.ts");@@ -78,8 +65,8 @@ function backend() {if (process.env.SLOPFAB_BACKEND === "cuda" || process.env.SLOPFAB_BACKEND === "vulkan") {return process.env.SLOPFAB_BACKEND;}- const devices = spawnSync(settings.executable, ["devices"], { encoding: "utf8", windowsHide: true });- return devices.status === 0 && /^device\s+\d+/m.test(devices.stdout || "") ? "cuda" : "vulkan";+ // The native DLL probes CUDA 13/12 and falls back to Vulkan itself.+ return "cuda";}function stylePrompt(entry) {@@ -160,11 +147,9 @@ function stableSeed(id) {return Number.parseInt(createHash("sha256").update(id).digest("hex").slice(0, 8), 16);}-async function generate(entry, temporaryDirectory, inferenceBackend) {- const destination = join(outputDirectory, `${entry.id}.jpg`);+async function previewGeneration(entry, temporaryDirectory, inferenceBackend) {const promptPath = join(temporaryDirectory, `${entry.id}.txt`);const rawBase = join(temporaryDirectory, `${entry.id}.mp4`);- const y4mPath = join(temporaryDirectory, `${entry.id}.y4m`);await writeFile(promptPath, promptFor(entry), "utf8");const args = [@@ -173,8 +158,8 @@ async function generate(entry, temporaryDirectory, inferenceBackend) {"--out", rawBase,"--raw","--resolution", "768x768",- // H3's decoder cannot accept one temporal frame. Six is the smallest legal- // request and resolves to 22; only frame zero is retained below.+ // The CLI dry-run validates the smallest legal video request; actual icons+ // use the DLL's still-image mode through the Rust worker below."--frames", "6","--steps", "20","--seed", String(stableSeed(entry.id)),@@ -185,20 +170,10 @@ async function generate(entry, temporaryDirectory, inferenceBackend) {"--vae", settings.videoVae,"--audio-vae", settings.audioVae,];- if (dryRun) args.push("--dry-run");+ args.push("--dry-run");- if (dryRun) console.log(`\n[${entry.name}] MiniMax H3, 768x768, 20 steps, ${inferenceBackend}`);- await (dryRun ? run : runQuiet)(settings.executable, args, { cwd: repository });- if (dryRun) return;- await run(settings.ffmpeg, [- "-hide_banner", "-loglevel", "error", "-y",- "-i", y4mPath,- "-frames:v", "1",- "-vf", "scale=256:256:flags=lanczos",- "-pix_fmt", "yuvj444p",- "-q:v", "1",- destination,- ]);+ console.log(`\n[${entry.name}] MiniMax H3, 768x768, 20 steps, ${inferenceBackend}`);+ await run(settings.executable, args, { cwd: repository });}const manifest = loadCatalog();@@ -249,7 +224,7 @@ try {pending.push(entry);}if (dryRun) {- for (const entry of pending) await generate(entry, temporaryDirectory, inferenceBackend);+ for (const entry of pending) await previewGeneration(entry, temporaryDirectory, inferenceBackend);} else if (pending.length > 0) {const specs = pending.map((entry) => ({id: entry.id,@@ -268,7 +243,7 @@ try {const executable = join(repository, "src-tauri", "target", "debug", "reference_icons.exe");const environment = {...process.env,- SLOPFAB_EXE: settings.executable,+ SLOPFAB_DLL: settings.dll,SLOPFAB_TRANSFORMER: settings.transformer,SLOPFAB_TEXT_ENCODER: settings.textEncoder,SLOPFAB_VIDEO_VAE: settings.videoVae,diff --git a/src-tauri/build.rs b/src-tauri/build.rsindex 06daf0d..6c69426 100644--- a/src-tauri/build.rs+++ b/src-tauri/build.rs@@ -1,5 +1,22 @@fn main() {// Recompile the executable's Windows resource when packaged icons change.println!("cargo:rerun-if-changed=icons");+ println!("cargo:rerun-if-changed=../lib/slopfab/slopfab.dll");+ validate_slopfab_runtime();tauri_build::build()}++fn validate_slopfab_runtime() {+ use std::{fs::File, io::Read, path::Path};++ // Fail before packaging an LFS pointer in place of the runtime DLL.+ let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("../lib/slopfab/slopfab.dll");+ let mut header = [0_u8; 2];+ File::open(path).and_then(|mut file| file.read_exact(&mut header))+ .unwrap_or_else(|error| panic!("Missing SlopFab runtime slopfab.dll: {error}. Run git lfs pull."));+ assert_eq!(&header, b"MZ", "Invalid SlopFab runtime slopfab.dll; it may be a Git LFS pointer. Run git lfs pull.");+ if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") {+ assert_eq!(std::env::var("CARGO_CFG_TARGET_ARCH").as_deref(), Ok("x86_64"),+ "The vendored SlopFab runtime currently supports Windows x64 only.");+ }+}diff --git a/src-tauri/src/bin/reference_icons.rs b/src-tauri/src/bin/reference_icons.rsindex d51dc4e..7b810d5 100644--- a/src-tauri/src/bin/reference_icons.rs+++ b/src-tauri/src/bin/reference_icons.rs@@ -1,4 +1,4 @@-use slopus_lib::{generate_reference_icon_batch, ReferenceIconBatchConfig, ReferenceIconSpec};+use slopus_lib::{default_dll_path, generate_reference_icon_batch, ReferenceIconBatchConfig, ReferenceIconSpec};use std::{env, fs, path::PathBuf};fn required(name: &str) -> Result<String, String> {@@ -16,7 +16,7 @@ fn run() -> Result<(), String> {generate_reference_icon_batch(&specs,&ReferenceIconBatchConfig {- dll_path: PathBuf::from(required("SLOPFAB_EXE")?).with_file_name("slopfab.dll"),+ dll_path: env::var_os("SLOPFAB_DLL").map(PathBuf::from).unwrap_or_else(default_dll_path),transformer: required("SLOPFAB_TRANSFORMER")?.into(),text_encoder: required("SLOPFAB_TEXT_ENCODER")?.into(),video_vae: required("SLOPFAB_VIDEO_VAE")?.into(),diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex b65433e..801e18b 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -16,7 +16,7 @@ mod reference_icons;mod rendered;mod slopfab;-pub use slopfab::{generate_reference_icon_batch, ReferenceIconBatchConfig, ReferenceIconSpec};+pub use slopfab::{default_dll_path, generate_reference_icon_batch, ReferenceIconBatchConfig, ReferenceIconSpec};const PROJECT_FILE_NAME: &str = "slopus.json";/// What the file was called before, newest first. Folders written by earlierdiff --git a/src-tauri/src/slopfab.rs b/src-tauri/src/slopfab.rsindex 6a89270..6ec5a22 100644--- a/src-tauri/src/slopfab.rs+++ b/src-tauri/src/slopfab.rs@@ -17,24 +17,17 @@ use std::{use tauri::{AppHandle, Emitter};const DLL_FILE_NAME: &str = "slopfab.dll";-/// Where the packaged build puts the runtime while it is being developed. Used-/// only when the DLL is NOT beside the executable, so a `cargo run` out of the-/// source tree still finds it.-const DEVELOPMENT_DLL_PATH: &str = r"D:\Projects\slopfab\build\Release\slopfab.dll";--/// The runtime ships beside Slopus.exe and is loaded from there — there is-/// no path for anyone to configure and no way for one to go stale. slopfab.dll-/// is loaded with LOAD_WITH_ALTERED_SEARCH_PATH, so its own dependencies sit in-/// that folder too, which is the same reason a subfolder never bought anything.+/// Tauri stages the repository's runtime resources in development and release+/// builds. Installers and portable folders use the same relative layout.pub fn default_dll_path() -> PathBuf {- if let Some(beside_exe) = std::env::current_exe()- .ok()- .and_then(|exe| exe.parent().map(|dir| dir.join(DLL_FILE_NAME)))- .filter(|path| path.is_file())- {- return beside_exe;- }- DEVELOPMENT_DLL_PATH.into()+ let executable = std::env::current_exe().unwrap_or_else(|_| PathBuf::from("Slopus.exe"));+ let directory = executable.parent().unwrap_or_else(|| Path::new("."));+ // Cargo test executables live one level below the staged resources.+ #[cfg(test)]+ let directory = if directory.file_name().is_some_and(|name| name == "deps") {+ directory.parent().unwrap_or(directory)+ } else { directory };+ directory.join(DLL_FILE_NAME)}const EXPECTED_CAPI_MAJOR: u32 = 1;const NOT_READY: i32 = -7;@@ -418,7 +411,7 @@ impl Configuration {Self {// `dllPath` is no longer written by the app and has no settings UI.// It is still READ so a project or a test that carries one keeps- // working; with none, the runtime is found beside the executable.+ // working; with none, use the DLL beside the executable.dll_path: option("dllPath").unwrap_or_else(default_dll_path),models: [(0, "transformer", option("transformer")),@@ -1461,24 +1454,21 @@ mod tests {assert_eq!(ComputePlatform::Vulkan.attention(), "exact");}- /// Under `cargo test` the executable is a test harness in target/debug, so- /// this resolves to the development path — which is exactly the build this- /// test is here to check.#[test]- fn installed_development_dll_reports_a_compatible_api_when_present() {- if default_dll_path().is_file() {- let runtime = status(&BTreeMap::new());- assert_ne!(runtime.state, "runtimeMissing", "{}", runtime.detail);- assert_ne!(runtime.state, "incompatible", "{}", runtime.detail);- assert!(runtime- .version- .as_deref()- .is_some_and(|value| value.starts_with("1.")));- assert!(matches!(- runtime.platform,- Some("CUDA 13" | "CUDA 12" | "Vulkan")- ));- }+ #[cfg(windows)]+ fn bundled_dll_reports_a_compatible_api() {+ assert!(default_dll_path().is_file(), "The build must stage slopfab.dll beside the executable.");+ let runtime = status(&BTreeMap::new());+ assert_ne!(runtime.state, "runtimeMissing", "{}", runtime.detail);+ assert_ne!(runtime.state, "incompatible", "{}", runtime.detail);+ assert!(runtime+ .version+ .as_deref()+ .is_some_and(|value| value.starts_with("1.")));+ assert!(matches!(+ runtime.platform,+ Some("CUDA 13" | "CUDA 12" | "Vulkan")+ ));}#[test]fn stage_ids_are_normalized_without_assuming_an_enum() {diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.jsonindex 42e2e6b..e72eada 100644--- a/src-tauri/tauri.conf.json+++ b/src-tauri/tauri.conf.json@@ -30,6 +30,9 @@},"bundle": {"active": true,+ "resources": {+ "../lib/slopfab/slopfab.dll": "slopfab.dll"+ },"targets": "all","icon": ["icons/32x32.png",