Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Add Cinder to Cap
Richie McIlroy7bd58e1e4083
diff --git a/AGENTS.md b/AGENTS.mdindex 11311e7e0..b6907a366 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -11,7 +11,7 @@ These rules are enforced by CI (`cargo clippy -D warnings`, Biome). Fixing them### Post-edit checks (run before you say "done")- Prefer scoped, fast checks over full workspace gates. Do not run long full-repo checks by default.-- Touched any Rust file → `cargo fmt --all` and `cargo check -p <crate>`. Add `--all-targets`, `--workspace`, or clippy only when explicitly requested, when preparing CI/PR final validation, or when the change needs broader coverage.+- Touched any Rust file → `cargo fmt --all` and `cargo check -p <crate>`. On macOS, if `cinder` is on `PATH`, use `cinder` instead of `cargo` for `check`, `build`, `test`, and `run` (not `fmt` or `clippy`). Add `--all-targets`, `--workspace`, or clippy only when explicitly requested, when preparing CI/PR final validation, or when the change needs broader coverage. Never use Cinder in CI or release builds.- Touched any TS / JS / JSON / CSS / MD file → run the narrowest applicable formatter/linter on touched files first, such as `pnpm exec biome check --write <files>`. Use full `pnpm format`, `pnpm lint`, and `pnpm typecheck` only when explicitly requested or when the change spans shared types/packages.- Touched DB schema → `pnpm db:generate` before relying on it.@@ -61,7 +61,7 @@ Additionally, `unused_must_use = "deny"` applies to all Rust code: every `Result- Build: `pnpm build` (Turbo). Desktop release: `pnpm tauri:build`.- DB: `pnpm db:generate` → `pnpm db:push` → `pnpm db:studio`.- Docker: `pnpm docker:up | docker:stop | docker:clean`.-- Quality: `pnpm lint`, `pnpm format`, `pnpm typecheck`. Rust: `cargo build -p <crate>`, `cargo test -p <crate>`.+- Quality: `pnpm lint`, `pnpm format`, `pnpm typecheck`. Rust: `cargo build -p <crate>`, `cargo test -p <crate>`. On macOS, prefer `cinder` over `cargo` for those local `build` / `test` / `check` / `run` commands when it is installed.## Coding Style & Naming- TypeScript / JS / JSON / CSS: **tab indent** and **double-quoted** strings, enforced by Biome (see `biome.json`). Do not configure per-file overrides.@@ -73,7 +73,7 @@ Additionally, `unused_must_use = "deny"` applies to all Rust code: every `Result## Testing- TS/JS: Vitest where present (e.g., desktop). Name tests `*.test.ts(x)` near sources.-- Rust: `cargo test` per crate; tests in `src` or `tests`.+- Rust: `cargo test` per crate; tests in `src` or `tests`. On macOS, use `cinder test` when Cinder is installed.- Prefer unit tests for logic and light smoke tests for flows; no strict coverage yet.## Commits & PRs@@ -110,6 +110,6 @@ Prefer the smallest correct fix, but only after checking whether the narrow fix## Code Formatting & Lint ChecksBefore declaring any task complete, the agent should run the fastest useful check for every file type it touched and report anything skipped.-- **Rust**: `cargo fmt --all` and `cargo check -p <crate>` for the touched crate. Add `--all-targets`, `--workspace`, or `cargo clippy -p <crate> --all-targets -- -D warnings` only for explicit requests, CI/PR final validation, or changes that need broader coverage.+- **Rust**: `cargo fmt --all` and `cargo check -p <crate>` for the touched crate. On macOS, if `cinder` is on `PATH`, run that check as `cinder check -p <crate>`. Add `--all-targets`, `--workspace`, or `cargo clippy -p <crate> --all-targets -- -D warnings` only for explicit requests, CI/PR final validation, or changes that need broader coverage.- **TS / JS / JSON / CSS / MD**: prefer scoped checks such as `pnpm exec biome check --write <files>`. Use full `pnpm format`, `pnpm lint`, and `pnpm typecheck` only when explicitly requested or when the change is broad enough to justify it.- If a scoped check fails, fix the violation in the source (do NOT suppress with `#[allow(...)]`, `// biome-ignore`, or `any` unless explicitly approved). The Pre-Generation Invariants show the correct form for every denied lint.diff --git a/README.md b/README.mdindex f8943348f..5face40ac 100644--- a/README.md+++ b/README.md@@ -120,6 +120,7 @@ Requirements:- pnpm 10.5.2- Rust 1.88 or newer- Docker for MySQL, MinIO, and local services+- Optional on macOS: [Cinder](https://github.com/CapSoftware/cinder) for faster local `check` / `build` / `test` / `run` and desktop watch. `pnpm dev:desktop` uses it automatically when `cinder` is on `PATH`. Install with `pnpm cinder:install`. Set `CAP_USE_CINDER=0` to force stock Cargo.Install and set up the repo:@@ -142,6 +143,7 @@ Common commands:| `pnpm format` | Format with Biome || `pnpm typecheck` | Run TypeScript project references || `cargo test -p <crate>` | Run Rust tests for a crate |+| `pnpm cinder:install` | Install Cinder for faster local macOS Rust commands |Database commands:diff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex 17e7b4f84..d8dcb0346 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -2,7 +2,7 @@"name": "@cap/desktop","type": "module","scripts": {- "dev": "pnpm -w cap-setup && pnpm build:sidecar && dotenv -e ../../.env -- pnpm run preparescript && dotenv -e ../../.env -- pnpm tauri dev",+ "dev": "pnpm -w cap-setup && pnpm build:sidecar && dotenv -e ../../.env -- pnpm run preparescript && dotenv -e ../../.env -- node ../../scripts/local-cargo.mjs pnpm tauri dev","build:tauri": "pnpm build:sidecar && dotenv -e ../../.env -- pnpm run preparescript && dotenv -e ../../.env -- pnpm tauri build","build:sidecar": "node ../../scripts/build-desktop-binaries.mjs","preparescript": "node scripts/prepare.js",diff --git a/package.json b/package.jsonindex 55c4e1879..197862c7d 100644--- a/package.json+++ b/package.json@@ -49,7 +49,8 @@"check-tauri-versions": "node scripts/check-tauri-plugin-versions.js","clean": "find . -name node_modules -o -name .next -o -name .output -o -name .turbo -o -name dist -type d -prune | xargs rm -rf","lgtm-otel": "docker run -p 3010:3000 -p 4317:4317 -p 4318:4318 --rm -it docker.io/grafana/otel-lgtm",- "with-env": "dotenv -e .env --"+ "cinder:install": "cargo install --git https://github.com/CapSoftware/cinder --locked",+ "with-env": "dotenv -e .env -- node scripts/local-cargo.mjs"},"devDependencies": {"@biomejs/biome": "2.2.0",diff --git a/scripts/local-cargo.mjs b/scripts/local-cargo.mjsnew file mode 100644index 000000000..c3ac5a419--- /dev/null+++ b/scripts/local-cargo.mjs@@ -0,0 +1,56 @@+import { spawn, spawnSync } from "node:child_process";+import path from "node:path";+import { fileURLToPath } from "node:url";++function findOnPath(name) {+ const command = process.platform === "win32" ? "where.exe" : "which";+ const result = spawnSync(command, [name], { encoding: "utf8" });+ if (result.status !== 0) return null;+ return result.stdout.trim().split(/\r?\n/).find(Boolean) ?? null;+}++export function resolveLocalCargo() {+ if (process.env.CAP_USE_CINDER === "0") return "cargo";+ if (process.env.CARGO) return process.env.CARGO;+ if (process.platform !== "darwin") return "cargo";+ return findOnPath("cinder") ?? "cargo";+}++export function usesCinder(cargo = resolveLocalCargo()) {+ return path.basename(cargo, ".exe") === "cinder";+}++export function localCargoEnv(env = process.env) {+ return { ...env, CARGO: resolveLocalCargo() };+}++export function withTauriDevRunner(args, cargo = resolveLocalCargo()) {+ if (!usesCinder(cargo) || args.includes("--runner")) return args;+ const tauriDev = args.findIndex(+ (argument, index) => argument === "tauri" && args[index + 1] === "dev",+ );+ if (tauriDev === -1) return args;+ return [...args, "--runner", cargo];+}++const isMain =+ process.argv[1] !== undefined &&+ path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);++if (isMain) {+ const cargo = resolveLocalCargo();+ const args = withTauriDevRunner(process.argv.slice(2), cargo);+ if (args.length === 0) {+ process.stdout.write(`${cargo}\n`);+ process.exit(0);+ }+ if (args[0] === "cargo") args[0] = cargo;+ const child = spawn(args[0], args.slice(1), {+ stdio: "inherit",+ env: { ...process.env, CARGO: cargo },+ });+ child.on("exit", (code, signal) => {+ if (signal) process.kill(process.pid, signal);+ else process.exit(code ?? 1);+ });+}diff --git a/scripts/setup.js b/scripts/setup.jsindex 9b42839ea..ca7b116f1 100644--- a/scripts/setup.js+++ b/scripts/setup.js@@ -6,6 +6,7 @@ import * as path from "node:path";import { env } from "node:process";import { fileURLToPath } from "node:url";import { promisify } from "node:util";+import { resolveLocalCargo, usesCinder } from "./local-cargo.mjs";const exec = promisify(execCb);const execFile = promisify(execFileCb);@@ -47,6 +48,15 @@ async function main() {);if (process.platform === "darwin") {+ const localCargo = resolveLocalCargo();+ if (usesCinder(localCargo))+ console.log(+ `Using Cinder at ${localCargo} for local macOS Cargo commands`,+ );+ else if (env.CAP_USE_CINDER === "0")+ console.log("Cinder disabled (CAP_USE_CINDER=0), using Cargo");+ else console.log("Cinder not found. Install with: pnpm cinder:install");+cargoConfigContents += FFMPEG_CARGO_ENV;const NATIVE_DEPS_VERSION = "v0.25";