Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,15 @@ jobs:
env:
CARGO_PROFILE_TEST_DEBUG: "0"
run: cargo test --locked -p raea-runtime-plugins -p raea-io-media -p raea-core-fonts -p raea-native -p raea-core-brief -p raea-core-k -p raea-bundle -p raea-app-check -p raea-app-check-flash -p raea-io-ffmpeg -p raea-app-workspace -p raea-app-tools -p raea-app-targets
- name: Windows' and Linux's own (#169)
# what a Windows or Linux user meets that no other step ran: QuickJS's Intl (raea-runtime-jsengine's
# quickjs_formats_as_javascriptcore_does, on Linux), openh264 at --quality master (raea-io-soft), git found or
# fetched (raea-io-assets), and raea's Node core under the agent shell (raea-native's tests/node.rs: Node's names
# for the system, Windows' paths); tests/node.rs needs raea-native's modules feature and tests/quality.rs
# raea-io-soft's h264
env:
CARGO_PROFILE_TEST_DEBUG: "0"
run: |
cargo test --locked -p raea-native --features modules --test node
cargo test --locked -p raea-io-soft --features h264
cargo test --locked -p raea-runtime-jsengine -p raea-io-assets
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ paths for Windows in runtime/bundle). Its bin\ also carries, each with its licen
uv (uv.exe; Astral, MIT OR Apache-2.0).
The Windows app adds Git for Windows with Git LFS (dugite-native; GPLv2 and its parts' licences, in git\), which raea
runs as a separate program; its complete corresponding source is published as the release tools-git-<tag>-sources.
raea.exe, on a PC with no Git, fetches the same build once into its tools cache (io/assets git()).
The Windows and Linux builds' JavaScript engine, QuickJS (rquickjs, MIT), carries FormatJS's Intl polyfills (MIT,
Copyright FormatJS) and the Unicode CLDR locale data they're made with (Unicode-3.0), packed in
runtime/jsengine/js/intl.pack; both licences are in runtime/jsengine/js/intl/LICENSE-FormatJS.md and in the pack.
The native target (engine/rune, docs/targets.feature) builds on Rune (https://github.com/anomalyco/rune, Copyright
2026 Anomaly, MIT; LICENSES/rune-0.0.1/repository-LICENSE): rune, rune-kit and their crates, by a pinned rev.

Expand Down
2 changes: 2 additions & 0 deletions apps/workspace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ dunce = "1"
# the controller schema (core/brief controller.rs): a controller file is checked and normalized against it
raea-core-brief = { path = "../../core/brief" }
raea-io-home = { path = "../../io/home" }
# git, which a workspace is: the PATH's, else on Windows the app's or raea's own (raea_io_assets::git)
raea-io-assets = { path = "../../io/assets" }
serde_json = "1"
# a project's compositions, components and controllers read from their source (docs/projects.feature PJ8)
raea-app-registry = { path = "registry" }
Expand Down
6 changes: 3 additions & 3 deletions apps/workspace/src/controllers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ pub(crate) fn overrides(from: &Path) -> Vec<(String, String)> {
}

fn commit(ws: &Path, paths: &[&Path], what: &str, by: &str) -> R<()> {
let mut add = Command::new("git");
let mut add = Command::new(workspace::program());
add.arg("-C").arg(ws).args(["add", "-A", "--"]).args(paths);
add.status().map_err(|e| format!("git: {e}"))?;
let ok = workspace::git_cmd().arg("-C").arg(ws).args(["-c", &format!("user.name={by}"), "commit", "-q", "-m", &format!("{by}: {what}"), "--"]).args(paths).status().map_err(|e| format!("git: {e}"))?;
add.status().map_err(workspace::missing)?;
let ok = workspace::git_cmd().arg("-C").arg(ws).args(["-c", &format!("user.name={by}"), "commit", "-q", "-m", &format!("{by}: {what}"), "--"]).args(paths).status().map_err(workspace::missing)?;
if ok.success() { Ok(()) } else { Err(format!("couldn't commit {what}")) }
}

Expand Down
32 changes: 26 additions & 6 deletions apps/workspace/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const USAGE: &str = "usage: raea workspace [--json] | raea workspace init [NAME]
/// full name (a CI runner's, a container's) has no name either ("empty ident name ... not allowed"), and git has no
/// fallback below user.name to give it, so when no user.name is set the author and committer are named for the account.
pub(crate) fn git_cmd() -> Command {
let mut c = Command::new("git");
let mut c = Command::new(program());
let user = std::env::var("USER").unwrap_or_else(|_| "raea".into());
if std::env::var_os("EMAIL").is_none() {
c.env("EMAIL", format!("{user}@raea.local"));
Expand All @@ -24,14 +24,33 @@ pub(crate) fn git_cmd() -> Command {
c
}

/// The git raea runs (raea_io_assets::git: the PATH's, else on Windows the app's or raea's own, fetched once), found
/// once a process; "git" when there's none, its spawn then failing as `missing` says.
fn found() -> &'static Result<std::path::PathBuf, String> {
static GIT: std::sync::OnceLock<Result<std::path::PathBuf, String>> = std::sync::OnceLock::new();
GIT.get_or_init(raea_io_assets::git)
}

pub(crate) fn program() -> std::path::PathBuf {
found().clone().unwrap_or_else(|_| "git".into())
}

/// A git that didn't start, said as why: there's no git here (and how to get one), or what the system said
pub(crate) fn missing(e: std::io::Error) -> String {
match found() {
Err(why) if e.kind() == std::io::ErrorKind::NotFound => why.clone(),
_ => format!("git: {e}"),
}
}

/// Whether git has a user.name to sign commits with (asked once a process).
fn has_name() -> bool {
static HAS: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
*HAS.get_or_init(|| Command::new("git").args(["config", "--get", "user.name"]).output().is_ok_and(|o| o.status.success() && !o.stdout.trim_ascii().is_empty()))
*HAS.get_or_init(|| Command::new(program()).args(["config", "--get", "user.name"]).output().is_ok_and(|o| o.status.success() && !o.stdout.trim_ascii().is_empty()))
}

pub(crate) fn git(dir: &Path, args: &[&str]) -> R<String> {
let out = git_cmd().arg("-C").arg(dir).args(args).output().map_err(|e| format!("git: {e}"))?;
let out = git_cmd().arg("-C").arg(dir).args(args).output().map_err(missing)?;
if !out.status.success() {
return Err(format!("git {}: {}", args.join(" "), String::from_utf8_lossy(&out.stderr).trim()));
}
Expand All @@ -40,12 +59,12 @@ pub(crate) fn git(dir: &Path, args: &[&str]) -> R<String> {

/// `git config` on a file (or the global config when `file` is None), its output trimmed; Err when git says no.
pub(crate) fn config(file: Option<&Path>, args: &[&str]) -> R<String> {
let mut c = Command::new("git");
let mut c = Command::new(program());
c.arg("config");
if let Some(f) = file {
c.arg("-f").arg(f);
}
let out = c.args(args).output().map_err(|e| format!("git: {e}"))?;
let out = c.args(args).output().map_err(missing)?;
if !out.status.success() {
return Err(format!("git config {}: {}", args.join(" "), String::from_utf8_lossy(&out.stderr).trim()));
}
Expand Down Expand Up @@ -111,7 +130,8 @@ pub fn default_root(home: &Path) -> PathBuf {
if home.join("Library/Mobile Documents/com~apple~CloudDocs/Documents").is_dir() {
home.join("raea")
} else {
home.join("Documents/raea")
// a folder at a time: on Windows "Documents/raea" printed as C:\Users\you\Documents/raea\...
home.join("Documents").join("raea")
}
}

Expand Down
190 changes: 190 additions & 0 deletions engine/cli/conformance/app.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
// `raea show` and its app on a Mac, Windows and Linux (src/app.ts), each system faked (a Here): where the running
// app's host is, which app is installed, how files open without it, how it's started, and the harness found up the
// processes. #169: on Windows `raea show` asked `kill` whether the app ran, looked only in /Applications, and said
// it had opened the files "in the Mac's own viewer".
import { afterAll, describe, expect, test } from "bun:test";
import { appHost, computer, harness, installedApp, openFiles, show, type Here } from "../src/app";
import { pixelsOf } from "../src/brand";
import { absolute, fromCwd } from "../src/show";

const WIN_KEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\raea";

/** A system: `platform`, its files (path → text), and its programs' answers; every run is kept in `ran`. */
function here(platform: string, files: Record<string, string> = {}, answer: (cmd: string, args: string[]) => { status?: number; stdout?: string } = () => ({})) {
const ran: string[][] = [];
const h: Here & { ran: string[][] } = {
platform,
ran,
run: (cmd, args) => {
ran.push([cmd, ...args]);
const a = answer(cmd, args);
return { status: a.status ?? 0, stdout: a.stdout ?? "" };
},
exists: (p) => p in files,
read: (p) => {
if (!(p in files)) throw new Error(`ENOENT ${p}`);
return files[p];
},
env: { RAEA_NO_OPEN: undefined },
home: platform === "win32" ? "C:/Users/me" : "/home/you",
};
return h;
}

// the app's host, as the window's (apps/app host/show.ts): an item's link for a show, and /host/shown to say it finds it.
// Its own process: show() posts with a synchronous curl, which a server in this one couldn't answer
const host = Bun.spawn(["bun", "-e", `const s = Bun.serve({ port: 0, fetch: (r) => { const p = new URL(r.url).pathname; return p === "/host/show" ? Response.json({ url: "raea://item/7" }) : p === "/host/shown" ? Response.json({}) : new Response("not found", { status: 404 }); } }); console.log(s.port);`], { stdout: "pipe" });
afterAll(() => host.kill());
/** its first line: the port it listens on */
async function portOf(out: ReadableStream<Uint8Array>) {
const r = out.getReader();
let text = "";
while (!text.includes("\n")) {
const { value, done } = await r.read();
if (done) throw new Error(`the test's host stopped before it listened: ${text}`);
text += new TextDecoder().decode(value);
}
r.releaseLock();
return Number(text.trim());
}
const HOST = `http://127.0.0.1:${await portOf(host.stdout)}`;

describe("the running app's host", () => {
test("on Windows, its pid is asked of tasklist (Windows has no kill)", () => {
const file = { "C:/Users/me/.raea/app-host.json": JSON.stringify({ url: HOST, pid: 4321 }) };
const up = here("win32", file, (cmd, args) => (cmd === "tasklist" && args.includes("PID eq 4321") ? { stdout: '"raea.exe","4321","Console","1","80,000 K"\r\n' } : {}));
expect(appHost(up)).toBe(HOST);
expect(up.ran.some(([c]) => c === "kill")).toBe(false);
// a file a stopped app left: tasklist finds no such process ("INFO: No tasks are running...")
const gone = here("win32", file, () => ({ stdout: "INFO: No tasks are running which match the specified criteria.\r\n" }));
expect(appHost(gone)).toBeNull();
});

test("on a Mac or Linux, kill -0", () => {
const file = { "/home/you/.raea/app-host.json": JSON.stringify({ url: HOST, pid: 99 }) };
expect(appHost(here("linux", file, (cmd) => ({ status: cmd === "kill" ? 0 : 1 })))).toBe(HOST);
expect(appHost(here("linux", file, (cmd) => ({ status: cmd === "kill" ? 1 : 0 })))).toBeNull();
});
});

describe("the installed app", () => {
test("on Windows, raea.exe in the folder its installer was given (Settings > Apps keeps it)", () => {
const reg = `\r\nHKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\raea\r\n InstallLocation REG_SZ D:\\Apps\\raea\r\n\r\n`;
const up = here("win32", { "D:\\Apps\\raea\\raea.exe": "" }, (cmd, args) => (cmd === "reg" && args[1] === WIN_KEY ? { stdout: reg } : {}));
expect(installedApp(up)).toBe("D:\\Apps\\raea\\raea.exe");
});

test("on Windows with no InstallLocation, the default folder", () => {
const up = here("win32", { "C:\\Users\\me\\AppData\\Local\\Programs\\raea\\raea.exe": "" }, () => ({ status: 1 }));
up.env.LOCALAPPDATA = "C:\\Users\\me\\AppData\\Local";
expect(installedApp(up)).toBe("C:\\Users\\me\\AppData\\Local\\Programs\\raea\\raea.exe");
});

test("on a Mac, raea.app in Applications; on Linux, the launcher raea.desktop runs", () => {
expect(installedApp(here("darwin", { "/Applications/raea.app": "" }))).toBe("/Applications/raea.app");
const desktop = "[Desktop Entry]\nName=raea\nExec=\"/home/you/.local/share/raea-app/launch.sh\"\n";
expect(installedApp(here("linux", { "/home/you/.local/share/applications/raea.desktop": desktop, "/home/you/.local/share/raea-app/launch.sh": "" }))).toBe("/home/you/.local/share/raea-app/launch.sh");
expect(installedApp(here("linux"))).toBeUndefined();
});
});

describe("raea show without the app", () => {
test("on Windows, each file opens in Windows' own viewer through Explorer, its path in Windows' slashes", () => {
const up = here("win32", {}, () => ({ status: 1 }));
const r = show({ files: ["C:/Users/me/cut & keep/a.mp4", "C:/Users/me/b.png"] }, up) as { opened: string[]; viewer: string };
expect(r.viewer).toBe("Windows' own viewer");
expect(up.ran.filter(([c]) => c === "explorer.exe")).toEqual([["explorer.exe", "C:\\Users\\me\\cut & keep\\a.mp4"], ["explorer.exe", "C:\\Users\\me\\b.png"]]);
expect(up.ran.some(([c]) => c === "open")).toBe(false);
});

test("a question needs the app, said for the system it runs on", () => {
expect(() => show({ files: [], question: "Which?" }, here("win32", {}, () => ({ status: 1 })))).toThrow("isn't on this PC");
expect(() => show({ files: [], question: "Which?" }, here("darwin"))).toThrow("isn't on this Mac");
expect(computer(here("linux")).name).toBe("this computer");
});

test("on Linux, xdg-open", () => {
const up = here("linux");
openFiles(["/home/you/a.mp4"], up);
expect(up.ran).toEqual([["xdg-open", "/home/you/a.mp4"]]);
});
});

describe("raea show starting the app", () => {
test("on Windows: raea.exe started through Explorer, its host waited for, the item posted, no raea:// link", () => {
const files: Record<string, string> = { "C:\\Users\\me\\AppData\\Local\\Programs\\raea\\raea.exe": "" };
const up = here("win32", files, (cmd, args) => {
// the app, once started, writes its host's address
if (cmd === "explorer.exe" && args[0].endsWith("raea.exe")) files["C:/Users/me/.raea/app-host.json"] = JSON.stringify({ url: HOST, pid: 77 });
if (cmd === "tasklist") return { stdout: '"raea.exe","77","Console","1","1 K"' };
return { status: cmd === "reg" ? 1 : 0 };
});
up.env.LOCALAPPDATA = "C:\\Users\\me\\AppData\\Local";
const r = show({ files: ["C:/Users/me/a.mp4"] }, up) as { url: string; brought: boolean };
expect(r).toEqual({ url: "raea://item/7", brought: false });
expect(up.ran.some(([c]) => c === "open" || c === "pgrep")).toBe(false);
});

test("on a Mac: open -a, and the window brought up on the item it was started for", () => {
const files: Record<string, string> = { "/Applications/raea.app": "" };
const up = here("darwin", files, (cmd, args) => {
if (cmd === "open" && args[0] === "-a") files["/home/you/.raea/app-host.json"] = JSON.stringify({ url: HOST, pid: 77 });
return { status: cmd === "pgrep" ? 1 : 0 };
});
expect(show({ files: ["/tmp/a.mp4"] }, up)).toEqual({ url: "raea://item/7", brought: true });
expect(up.ran.at(-1)).toEqual(["open", "raea://item/7"]);
});
});

describe("the harness that ran raea show", () => {
test("on Windows, found up every process's record from one PowerShell call, claude.exe as claude", () => {
const list = [`${process.pid}\t500\t"C:\\Users\\me\\raea\\bin\\raea.exe" show a.mp4`, `500\t400\t"C:\\Users\\me\\.local\\bin\\claude.exe" --resume`, `400\t1\tC:\\Windows\\explorer.exe`].join("\r\n");
const up = here("win32", {}, (cmd) => (cmd === "powershell" ? { stdout: list } : { status: 1 }));
expect(harness(up)).toEqual({ name: "Claude Code", pid: 500 });
expect(up.ran.filter(([c]) => c === "powershell")).toHaveLength(1);
});

test("a runtime's script by its name, the quoted path's spaces kept", () => {
const list = [`${process.pid}\t600\traea.exe show`, `600\t1\t"C:\\Program Files\\nodejs\\node.exe" C:\\Users\\me\\AppData\\Roaming\\npm\\gemini.cmd`].join("\n");
expect(harness(here("win32", {}, () => ({ stdout: list })))).toEqual({ name: "Gemini", pid: 600 });
});

test("on a Mac or Linux, ps up from the parent", () => {
const up = here("linux", {}, (cmd, args) => (cmd === "ps" && args.at(-1) === String(process.ppid) ? { stdout: " 1 /usr/local/bin/codex exec" } : { stdout: "" }));
expect(harness(up)).toEqual({ name: "Codex", pid: process.ppid });
});
});

describe("a path from the cwd", () => {
test("a Windows one is absolute, with either slash, a share's too", () => {
for (const p of ["C:\\Users\\me\\a.mp4", "c:/x", "\\\\nas\\clips\\a.mp4", "\\x", "/x"]) expect(absolute(p)).toBe(true);
for (const p of ["a.mp4", "cuts\\a.mp4", "C:a.mp4", "./a"]) expect(absolute(p)).toBe(false);
expect(fromCwd("C:/Users/me/proj", "D:\\clips\\a.mp4")).toBe("D:\\clips\\a.mp4");
expect(fromCwd("C:/Users/me/proj/", "out\\a.png")).toBe("C:/Users/me/proj/out\\a.png");
expect(fromCwd("/home/you", "a.png")).toBe("/home/you/a.png");
});
});

describe("a logo's pixels, on any system", () => {
// until 0.1.8 asked of sips, a Mac's: on Windows and Linux every raster logo in brand.json had no size. Each is the
// head of a 37x23 image from a real encoder (ffmpeg's PNG, GIF and ICO; cwebp's lossy and lossless; Pillow's WebP with
// alpha, VP8X; sips's JPEG, an Exif and a Photoshop block before its frame; ImageMagick's progressive JPEG)
const HEADS: Record<string, string> = {
png: "iVBORw0KGgoAAAANSUhEUgAAACUAAAAX",
gif: "R0lGODlhJQAXAA==",
"webp lossy": "UklGRiACAABXRUJQVlA4IBQCAAAwDwCdASolABcA",
"webp lossless": "UklGRrIAAABXRUJQVlA4TKUAAAAvJIAF",
"webp with alpha": "UklGRkwCAABXRUJQVlA4IEACAABQDwCdASolABcA",
ico: "AAABAAEAJRc=",
jpeg: "/9j/4AAQSkZJRgABAQAASABIAAD/4QBMRXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAJaADAAQAAAABAAAAFwAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgAFwAlAw==",
"jpeg progressive": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/2wBDAQMDAwQDBAgEBAgQCwkLEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBD/wgARCAAXACUD",
};
for (const [kind, head] of Object.entries(HEADS)) {
test(kind, () => expect(pixelsOf(Buffer.from(head, "base64"))).toEqual({ width: 37, height: 23 }));
}
test("anything else, or a header cut short, has none", () => {
expect(pixelsOf(new TextEncoder().encode("II*\0 a TIFF"))).toBeUndefined();
expect(pixelsOf(Buffer.from(HEADS.png, "base64").subarray(0, 18))).toBeUndefined();
expect(pixelsOf(new Uint8Array())).toBeUndefined();
});
});
Loading
Loading