Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(cli): embed cap-demo companion skill in agent installer
Richie McIlroy7ae8cf9da985
diff --git a/.gitignore b/.gitignoreindex 81b687fe8..df6630aa3 100644--- a/.gitignore+++ b/.gitignore@@ -9,6 +9,7 @@ lerna-debug.log*.deepsecnode_modules+apps/cli/skill/cap-demo/node_modules/distdist-ssr*.localdiff --git a/Cargo.lock b/Cargo.lockindex 9a10a9e4c..88ca9aca6 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1213,6 +1213,7 @@ dependencies = ["flume","futures","image 0.25.8",+ "include_dir","kameo","keyring","libc",@@ -4984,6 +4985,25 @@ version = "0.1.9"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e8a5a9a0ff0086c7a148acb942baaabeadf9504d10400b5a05645853729b9cd2"+[[package]]+name = "include_dir"+version = "0.7.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd"+dependencies = [+ "include_dir_macros",+]++[[package]]+name = "include_dir_macros"+version = "0.7.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75"+dependencies = [+ "proc-macro2",+ "quote",+]+[[package]]name = "indenter"version = "0.3.4"diff --git a/apps/cli/Cargo.toml b/apps/cli/Cargo.tomlindex e8fb5b520..16648093c 100644--- a/apps/cli/Cargo.toml+++ b/apps/cli/Cargo.toml@@ -28,6 +28,7 @@ kameo = "0.17.2"flume = { workspace = true }futures = { workspace = true }dirs = "6.0.0"+include_dir = "0.7"image = "0.25.2"chrono = "0.4.31"base64 = "0.22.1"diff --git a/apps/cli/build.rs b/apps/cli/build.rsnew file mode 100644index 000000000..b99bd3ea5--- /dev/null+++ b/apps/cli/build.rs@@ -0,0 +1,36 @@+use std::path::Path;++// The cap-demo skill directory is embedded wholesale into the `cap` binary via+// `include_dir!` in src/agents.rs. That macro has no exclusion filter and does+// not respect .gitignore, so anything on disk under skill/cap-demo at build+// time gets baked into every binary built from this checkout. The skill's own+// docs instruct running `npm install` inside that directory (it uses+// Playwright), which would silently embed the entire node_modules tree —+// including playwright-core — bloating the shipped CLI and making builds+// non-reproducible. Guard against that here, loudly, at build time.+fn main() {+ let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is set");+ let node_modules = Path::new(&manifest_dir)+ .join("skill")+ .join("cap-demo")+ .join("node_modules");++ // Re-run this check whenever the embedded skill tree changes (including+ // when node_modules appears or disappears).+ println!("cargo:rerun-if-changed=skill/cap-demo");++ if node_modules.exists() {+ println!(+ "cargo:warning=skill/cap-demo/node_modules exists and would be embedded into the cap binary by include_dir!"+ );+ panic!(+ "\n\nskill/cap-demo/node_modules exists at build time.\n\+ The entire skill/cap-demo directory is embedded into the `cap` binary via \+ include_dir! (src/agents.rs), which does not respect .gitignore, so building \+ now would bake the whole node_modules tree (including playwright-core) into \+ every binary built from this checkout.\n\n\+ Fix: rm -rf apps/cli/skill/cap-demo/node_modules\n\+ (npm dependencies there are only needed at cap-demo runtime, never at build time.)\n\n"+ );+ }+}diff --git a/apps/cli/skill/cap/SKILL.md b/apps/cli/skill/cap/SKILL.mdindex ad552ebc1..68f6f60c0 100644--- a/apps/cli/skill/cap/SKILL.md+++ b/apps/cli/skill/cap/SKILL.md@@ -115,3 +115,10 @@ cap upload out.mp4 --json```A stopped recording is complete only when `recordingMetaExists` is `true`.++## Cinematic demo videos++To generate a short, cinematic 3D product-demo video from a URL, use the installed+`cap-demo` skill (installed alongside this one). It scouts the page, records it with+virtual input, and treats it with Cap's 3D camera, a brand-matched background, and+music. Currently macOS-only.diff --git a/apps/cli/src/agents.rs b/apps/cli/src/agents.rsindex 55d5a8ba6..478c64887 100644--- a/apps/cli/src/agents.rs+++ b/apps/cli/src/agents.rs@@ -12,6 +12,26 @@ use crate::{OutputFormat, atomic, resolve_format, write_json};const BUNDLED_SKILL: &str = include_str!("../skill/cap/SKILL.md");+// The cap-demo companion skill ships as a directory tree (scripts, cursor and+// music assets) embedded into the binary alongside the main cap skill.+static CAP_DEMO_SKILL: include_dir::Dir<'static> =+ include_dir::include_dir!("$CARGO_MANIFEST_DIR/skill/cap-demo");++// Flatten every embedded file (recursively) so each becomes its own install+// change. include_dir gives direct files via `files()` and nested dirs via+// `dirs()`; file paths are already relative to the embedded root.+fn collect_demo_files<'a>(+ dir: &'a include_dir::Dir<'a>,+ out: &mut Vec<&'a include_dir::File<'a>>,+) {+ for file in dir.files() {+ out.push(file);+ }+ for sub in dir.dirs() {+ collect_demo_files(sub, out);+ }+}+#[derive(Args)]pub struct AgentsArgs {#[command(subcommand)]@@ -97,6 +117,19 @@ fn skill_path(target: AgentTarget) -> Result<PathBuf, String> {})}+// The cap-demo skill installs as a directory sibling of the cap skill.+fn cap_demo_skill_dir(target: AgentTarget) -> Result<PathBuf, String> {+ let home = home_dir()?;+ Ok(match target {+ AgentTarget::Codex => std::env::var_os("CODEX_HOME")+ .map(PathBuf::from)+ .unwrap_or_else(|| home.join(".codex"))+ .join("skills/cap-demo"),+ AgentTarget::Claude => home.join(".claude/skills/cap-demo"),+ AgentTarget::Cursor => home.join(".cursor/skills/cap-demo"),+ })+}+fn mcp_path(target: AgentTarget) -> Result<PathBuf, String> {let home = home_dir()?;Ok(match target {@@ -262,6 +295,37 @@ impl InstallArgs {expected,content,});++ // Ship the cap-demo companion skill as one change per embedded file.+ let demo_dir = cap_demo_skill_dir(self.target)?;+ let mut demo_files = Vec::new();+ collect_demo_files(&CAP_DEMO_SKILL, &mut demo_files);+ demo_files.sort_by(|a, b| a.path().cmp(b.path()));+ for file in demo_files {+ let relative = file.path();+ let dest = demo_dir.join(relative);+ let expected = read_optional(&dest)?;+ let bytes = file.contents();+ let action = if expected.as_deref() == Some(bytes) {+ "unchanged"+ } else if expected.is_some() {+ "replace"+ } else {+ "create"+ };+ let content = (action != "unchanged").then(|| bytes.to_vec());+ changes.push(PlannedChange {+ component: "skill",+ path: dest,+ action,+ value: json!({+ "name": "cap-demo",+ "file": relative.to_string_lossy(),+ }),+ expected,+ content,+ });+ }}if self.includes_mcp() {let path = mcp_path(self.target)?;