The VS Code of video editing, built for agents.
TypeScript
Add skills staging and installation enhancements
konstantin-paulusb441cba6d0f0
diff --git a/apps/desktop/.gitignore b/apps/desktop/.gitignoreindex 0410c18b..5f140748 100644--- a/apps/desktop/.gitignore+++ b/apps/desktop/.gitignore@@ -3,3 +3,4 @@ weboutclidocs+skillsdiff --git a/apps/desktop/forge.config.ts b/apps/desktop/forge.config.tsindex e4dbe0e6..5cfa8ce6 100644--- a/apps/desktop/forge.config.ts+++ b/apps/desktop/forge.config.ts@@ -27,9 +27,9 @@ const config: ForgeConfig = {!path.startsWith('/dist/') &&path !== '/web' &&!path.startsWith('/web/'),- // Staged by scripts/stage-cli.mjs and stage-docs.mjs; end up at- // Contents/Resources/{cli,docs}.- extraResource: ['./cli', './docs'],+ // Staged by scripts/stage-{cli,docs,skills}.mjs; end up at+ // Contents/Resources/{cli,docs,skills}.+ extraResource: ['./cli', './docs', './skills'],osxSign: process.env.SKIP_SIGN ? undefined : {},osxNotarize:process.env.APPLE_ID && process.env.APPLE_PASSWORD && process.env.APPLE_TEAM_IDdiff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex 6fc62449..cd70edf5 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -16,11 +16,12 @@"build:web": "npm --prefix ../web run build:desktop","stage:cli": "npm --prefix ../cli run build && node scripts/stage-cli.mjs","stage:docs": "node scripts/stage-docs.mjs",+ "stage:skills": "node scripts/stage-skills.mjs","check": "tsc --noEmit","dev": "npm run build && electron-forge start",- "package": "npm run build && npm run build:web && npm run stage:cli && npm run stage:docs && electron-forge package",- "make": "npm run build && npm run build:web && npm run stage:cli && npm run stage:docs && electron-forge make",- "publish": "npm run build && npm run build:web && npm run stage:cli && npm run stage:docs && electron-forge publish",+ "package": "npm run build && npm run build:web && npm run stage:cli && npm run stage:docs && npm run stage:skills && electron-forge package",+ "make": "npm run build && npm run build:web && npm run stage:cli && npm run stage:docs && npm run stage:skills && electron-forge make",+ "publish": "npm run build && npm run build:web && npm run stage:cli && npm run stage:docs && npm run stage:skills && electron-forge publish","make:icns": "sh scripts/make-icns.sh"},"devDependencies": {diff --git a/apps/desktop/scripts/stage-skills.mjs b/apps/desktop/scripts/stage-skills.mjsnew file mode 100644index 00000000..119d3b20--- /dev/null+++ b/apps/desktop/scripts/stage-skills.mjs@@ -0,0 +1,51 @@+/* This Source Code Form is subject to the terms of the Mozilla Public+ * License, v. 2.0. If a copy of the MPL was not distributed with this+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */++// Stages the agent skills into apps/desktop/skills so electron-forge can ship+// them as an app resource (Contents/Resources/skills). The app symlinks agent+// skill directories at these staged copies (see src/skills-install.ts), so+// auto-updates keep installed skills in lockstep with the dapi they document.+//+// Prefers a sibling checkout of diffusionstudio/skills next to the repo root+// (the dev setup); falls back to a shallow clone (CI).++import { execFileSync } from "node:child_process";+import { cpSync, existsSync, mkdirSync, mkdtempSync, readdirSync, rmSync } from "node:fs";+import { tmpdir } from "node:os";+import { dirname, join } from "node:path";+import { fileURLToPath } from "node:url";++const SKILLS_REPO = "https://github.com/diffusionstudio/skills.git";++const desktopDir = join(dirname(fileURLToPath(import.meta.url)), "..");+const repoRoot = join(desktopDir, "..", "..");+const stageDir = join(desktopDir, "skills");+const sibling = join(repoRoot, "..", "skills");++let sourceDir = sibling;+let tempDir = null;+if (!existsSync(join(sibling, "editor", "SKILL.md"))) {+ tempDir = mkdtempSync(join(tmpdir(), "stage-skills-"));+ execFileSync("git", ["clone", "--depth", "1", SKILLS_REPO, tempDir], { stdio: "inherit" });+ sourceDir = tempDir;+}++// A skill is a top-level directory with a SKILL.md.+const skills = readdirSync(sourceDir, { withFileTypes: true })+ .filter((e) => e.isDirectory() && !e.name.startsWith("."))+ .filter((e) => existsSync(join(sourceDir, e.name, "SKILL.md")))+ .map((e) => e.name);++if (skills.length === 0) {+ throw new Error(`stage-skills: no skills found in ${sourceDir}`);+}++rmSync(stageDir, { recursive: true, force: true });+mkdirSync(stageDir, { recursive: true });+for (const name of skills) {+ cpSync(join(sourceDir, name), join(stageDir, name), { recursive: true });+}+if (tempDir) rmSync(tempDir, { recursive: true, force: true });++console.log(`stage-skills: staged ${skills.join(", ")} at ${stageDir}`);diff --git a/apps/desktop/src/main-channels.ts b/apps/desktop/src/main-channels.tsindex 78017ae9..5df8bb83 100644--- a/apps/desktop/src/main-channels.ts+++ b/apps/desktop/src/main-channels.ts@@ -112,11 +112,10 @@ export type CliInstallResult =| { status: "cancelled" }| { status: "error"; error: string };-// Outcome of running the skills CLI. `npxMissing` marks a machine without a-// usable Node/npx, where the renderer falls back to copy-the-command.+// Outcome of symlinking the bundled skills into the agent skill directories.export type SkillsInstallResult =| { status: "installed" }- | { status: "error"; error: string; npxMissing: boolean };+ | { status: "error"; error: string };export type { SourceEdit, WriteResult };diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.tsindex 044ea250..b965b054 100644--- a/apps/desktop/src/main.ts+++ b/apps/desktop/src/main.ts@@ -10,7 +10,7 @@ import type { FileHandle } from "node:fs/promises";import { updateElectronApp } from "update-electron-app";import { startCliServer, stopCliServer, isHeadless } from "./cli-server";import { installCli, isCliInstalled } from "./cli-install";-import { installSkills, isSkillsInstalled } from "./skills-install";+import { healSkillsLinks, installSkills, isSkillsInstalled } from "./skills-install";import { trackInstall } from "./analytics";import { setupAppMenu } from "./menu";import { mainBridge } from "./main-manager";@@ -360,6 +360,7 @@ if (app.requestSingleInstanceLock()) {if (url) deliverDeepLink(url);startCliServer();+ healSkillsLinks();trackInstall();createWindow(!isHiddenLaunch(process.argv));});diff --git a/apps/desktop/src/skills-install.ts b/apps/desktop/src/skills-install.tsindex 4ad257e3..c7cd4dd5 100644--- a/apps/desktop/src/skills-install.ts+++ b/apps/desktop/src/skills-install.ts@@ -2,41 +2,190 @@* License, v. 2.0. If a copy of the MPL was not distributed with this* file, You can obtain one at http://mozilla.org/MPL/2.0/. */-import { execFile } from "node:child_process";-import { existsSync } from "node:fs";+import { app } from "electron";+import { existsSync, lstatSync, mkdirSync, readdirSync, readlinkSync, rmSync, symlinkSync } from "node:fs";import { homedir } from "node:os";-import { join } from "node:path";+import { dirname, join } from "node:path";import type { SkillsInstallResult } from "./main-channels";-// The skills CLI (github.com/vercel-labs/skills) installs global skills into-// ~/<agent>/skills/. `editor` is this product's main skill, so its presence-// under any known agent directory counts as installed.-const AGENT_DIRS = [".claude", ".codex", ".cursor", ".gemini", ".copilot"];+const AGENT_SKILLS_DIRS = [+ ".adal/skills",+ ".agents/skills",+ ".aider-desk/skills",+ ".astrbot/data/skills",+ ".augment/skills",+ ".autohand/skills",+ ".bob/skills",+ ".claude/skills",+ ".clawdbot/skills",+ ".codeartsdoer/skills",+ ".codebuddy/skills",+ ".codeium/windsurf/skills",+ ".codemaker/skills",+ ".codestudio/skills",+ ".codex/skills",+ ".commandcode/skills",+ ".config/agents/skills",+ ".config/crush/skills",+ ".config/devin/skills",+ ".config/goose/skills",+ ".config/kimchi/harness/skills",+ ".config/opencode/skills",+ ".continue/skills",+ ".copilot/skills",+ ".cursor/skills",+ ".deepagents/agent/skills",+ ".factory/skills",+ ".firebender/skills",+ ".forge/skills",+ ".gemini/antigravity-cli/skills",+ ".gemini/antigravity/skills",+ ".gemini/skills",+ ".grok/skills",+ ".hermes/skills",+ ".iflow/skills",+ ".inferencesh/skills",+ ".jazz/skills",+ ".junie/skills",+ ".kilocode/skills",+ ".kiro/skills",+ ".kode/skills",+ ".lingma/skills",+ ".mcpjam/skills",+ ".minimax/skills",+ ".moltbot/skills",+ ".moxby/skills",+ ".mux/skills",+ ".neovate/skills",+ ".ona/skills",+ ".openclaw/skills",+ ".openhands/skills",+ ".pi/agent/skills",+ ".pochi/skills",+ ".posit/assistant/skills",+ ".qoder-cn/skills",+ ".qoder/skills",+ ".qwen/skills",+ ".reasonix/skills",+ ".roo/skills",+ ".rovodev/skills",+ ".snowflake/cortex/skills",+ ".tabnine/agent/skills",+ ".terramind/skills",+ ".tinycloud/skills",+ ".trae-cn/skills",+ ".trae/skills",+ ".vibe/skills",+ ".zcode/skills",+ ".zencoder/skills",+];-export const SKILLS_INSTALL_COMMAND = "npx -y skills add diffusionstudio/skills -g -y --all";+const FALLBACK_AGENT_DIR = ".claude/skills";-const INSTALL_TIMEOUT_MS = 180_000;+function stagedSkillsDir(): string {+ return app.isPackaged+ ? join(process.resourcesPath, "skills")+ : join(app.getAppPath(), "skills");+}++function stagedSkillNames(): string[] {+ const dir = stagedSkillsDir();+ if (!existsSync(dir)) return [];+ return readdirSync(dir, { withFileTypes: true })+ .filter((entry) => entry.isDirectory())+ .map((entry) => entry.name);+}++// Agents whose config dir exists on this machine, falling back to Claude Code+// so a machine with no agent yet still gets set up for the primary one.+function targetAgentDirs(): string[] {+ const home = homedir();+ const present = AGENT_SKILLS_DIRS.filter((dir) => existsSync(join(home, dirname(dir))));+ return (present.length > 0 ? present : [FALLBACK_AGENT_DIR]).map((dir) => join(home, dir));+}+// `existsSync` follows symlinks, so a dangling link doesn't count.export function isSkillsInstalled(): boolean {const home = homedir();- return AGENT_DIRS.some((dir) => existsSync(join(home, dir, "skills", "editor")));+ const marker = stagedSkillNames()[0] ?? "editor";+ return AGENT_SKILLS_DIRS.some((dir) => existsSync(join(home, dir, marker, "SKILL.md")));}-// npx comes from the user's own Node install, which a Finder-launched app-// doesn't have on PATH — so the command runs through the user's login shell.-export function installSkills(): Promise<SkillsInstallResult> {- const shell = process.env.SHELL || "/bin/zsh";- return new Promise((resolve) => {- execFile(- shell,- ["-lc", SKILLS_INSTALL_COMMAND],- { timeout: INSTALL_TIMEOUT_MS },- (err, _stdout, stderr) => {- if (!err) return resolve({ status: "installed" });- const message = stderr.trim() || err.message;- const npxMissing = /command not found|not recognized|ENOENT/i.test(message);- resolve({ status: "error", error: message, npxMissing });- },- );- });+// ln -sf semantics that never clobber real files: an existing symlink is+// repointed (ours or the skills CLI's — the user asked to install), but a+// real directory (a `skills add --copy` install) is left alone.+function linkSkill(linkPath: string, target: string): void {+ try {+ if (!lstatSync(linkPath).isSymbolicLink()) return;+ rmSync(linkPath);+ } catch {+ // nothing at linkPath+ }+ symlinkSync(target, linkPath);+}++export function installSkills(): SkillsInstallResult {+ const source = stagedSkillsDir();+ // A quarantined first launch runs from a translocated read-only mount whose+ // path won't survive the next launch — linking to it would dangle.+ if (source.includes("/AppTranslocation/")) {+ return {+ status: "error",+ error: "Move Diffusion Studio to the Applications folder and relaunch it, then try again.",+ };+ }+ const skills = stagedSkillNames();+ if (skills.length === 0) {+ return {+ status: "error",+ error: app.isPackaged+ ? "The app bundle is missing its skills resources."+ : "Skills are not staged — run `npm run stage:skills` in apps/desktop.",+ };+ }+ try {+ for (const agentDir of targetAgentDirs()) {+ mkdirSync(agentDir, { recursive: true });+ for (const name of skills) {+ linkSkill(join(agentDir, name), join(source, name));+ }+ }+ return { status: "installed" };+ } catch (e) {+ return { status: "error", error: (e as Error).message };+ }+}++/**+ * Launch-time self-heal: links created by installSkills break when the app+ * moves or was translocated when they were made. Any symlink that targets a+ * Diffusion Studio bundle but not the running app's resources is repointed.+ * Links owned by the skills CLI and copied installs are left alone.+ */+export function healSkillsLinks(): void {+ if (!app.isPackaged) return;+ const source = stagedSkillsDir();+ if (source.includes("/AppTranslocation/")) return;++ const home = homedir();+ for (const dir of AGENT_SKILLS_DIRS) {+ for (const name of stagedSkillNames()) {+ const linkPath = join(home, dir, name);+ let target: string;+ try {+ target = readlinkSync(linkPath);+ } catch {+ continue; // missing, or not a symlink+ }+ const ours = target.includes("Diffusion Studio") || target.includes("/AppTranslocation/");+ const current = join(source, name);+ if (!ours || target === current) continue;+ try {+ rmSync(linkPath);+ symlinkSync(current, linkPath);+ } catch {+ // best effort — the install button remains as a manual fix+ }+ }+ }}diff --git a/apps/web/src/pages/onboarding.tsx b/apps/web/src/pages/onboarding.tsxindex 10ab508d..268dc3e9 100644--- a/apps/web/src/pages/onboarding.tsx+++ b/apps/web/src/pages/onboarding.tsx@@ -85,11 +85,6 @@ export function OnboardingPage() {const isDesktop = !!window.desktop;const [cliState, setCliState] = createSignal<StepState>('todo');const [skillsState, setSkillsState] = createSignal<StepState>('todo');- // On the web (and on desktop machines without Node) the skills CLI can't- // run, so the button degrades to copying the command.- const [skillsMode, setSkillsMode] = createSignal<'install' | 'copy'>(- isDesktop ? 'install' : 'copy',- );onMount(async () => {if (!isDesktop) return;@@ -156,15 +151,7 @@ export function OnboardingPage() {return;}setSkillsState('todo');- if (result.npxMissing) {- setSkillsMode('copy');- toast('Node.js required', {- description:- 'Installing needs npx, which was not found. Copy the command and run it where Node.js is available.',- });- } else {- toast('Could not install the agent skills', { description: result.error });- }+ toast('Could not install the agent skills', { description: result.error });} catch (error) {setSkillsState('todo');toast('Could not install the agent skills', {@@ -233,7 +220,7 @@ export function OnboardingPage() {title="Agent skills"description="Instructions that help agents edit videos through dapi."action={- skillsMode() === 'install' ? (+ isDesktop ? (<StepButtonstate={skillsState()}label="Install"