@clipy/cli 0.12.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Opening a URL in the user's default browser, safely on every platform.
3
+ *
4
+ * The Windows path is the whole reason this module exists. `cmd.exe` parses
5
+ * `&` as a command separator, and Node does NOT escape cmd metacharacters when
6
+ * it builds a command line — it only adds quotes around arguments containing
7
+ * whitespace or quotes. So spawning
8
+ *
9
+ * cmd /c start "" https://clipy.online/cli/authorize?challenge=A&state=B&port=1234
10
+ *
11
+ * opened `…?challenge=A` and then tried to run `state=B` as a separate command.
12
+ * Every Windows user landed on the "This authorization link is invalid" page,
13
+ * because the approval page requires state/port/name/scopes too.
14
+ *
15
+ * The fix follows the current `open` package approach: pass a Base64-encoded
16
+ * command directly to PowerShell. The URL never enters cmd.exe, and PowerShell
17
+ * decodes it only after command-line parsing, so `&` and percent-encoded values
18
+ * arrive unchanged.
19
+ */
20
+ import { spawn } from "node:child_process";
21
+ /**
22
+ * Build the spawn plan for a URL. Exported separately from the spawn so tests
23
+ * can assert the Windows command line without running on Windows.
24
+ */
25
+ export function planOpenUrl(url, platform) {
26
+ if (platform === "win32") {
27
+ const escapedUrl = url.replace(/'/g, "''");
28
+ const encodedCommand = Buffer.from(`Start-Process '${escapedUrl}'`, "utf16le").toString("base64");
29
+ return {
30
+ cmd: "powershell.exe",
31
+ args: ["-NoProfile", "-NonInteractive", "-EncodedCommand", encodedCommand],
32
+ verbatim: false,
33
+ };
34
+ }
35
+ return {
36
+ cmd: platform === "darwin" ? "open" : "xdg-open",
37
+ args: [url],
38
+ verbatim: false,
39
+ };
40
+ }
41
+ /**
42
+ * Fire-and-forget: spawn the OS opener and detach. Never throws — callers
43
+ * always print the URL as a fallback, which is the real safety net when no
44
+ * opener exists (headless boxes, stripped containers).
45
+ */
46
+ export function openUrl(url, platform = process.platform) {
47
+ const plan = planOpenUrl(url, platform);
48
+ try {
49
+ const child = spawn(plan.cmd, plan.args, {
50
+ detached: true,
51
+ stdio: "ignore",
52
+ windowsVerbatimArguments: plan.verbatim,
53
+ });
54
+ child.on("error", () => { }); // opener missing — the printed URL is the fallback
55
+ child.unref();
56
+ }
57
+ catch {
58
+ // ignore — the caller already printed the URL
59
+ }
60
+ }
@@ -11,7 +11,7 @@ function evenDimension(value, label) {
11
11
  throw new Error(`${label} must be an integer between 320 and 3840`);
12
12
  }
13
13
  if (value % 2 !== 0) {
14
- throw new Error(`${label} must be even for WebM encoding`);
14
+ throw new Error(`${label} must be even for video encoding`);
15
15
  }
16
16
  return value;
17
17
  }
@@ -45,7 +45,7 @@ function validateFrames(paths) {
45
45
  });
46
46
  }
47
47
  /**
48
- * Turns a bounded sequence of screenshots into a silent WebM. Each screenshot
48
+ * Turns a bounded sequence of screenshots into a silent MP4. Each screenshot
49
49
  * is held for the same duration; narration/captions remain separate so the
50
50
  * server can expose them as timestamped agent evidence.
51
51
  *
@@ -68,12 +68,12 @@ export async function renderProofFrames(opts) {
68
68
  for (const framePath of framePaths) {
69
69
  args.push("-loop", "1", "-t", String(opts.holdSeconds), "-i", framePath);
70
70
  }
71
- const filters = framePaths.map((_frame, index) => `[${index}:v]scale=${width}:${height}:force_original_aspect_ratio=decrease,` +
71
+ const filters = framePaths.map((_frame, index) => `[${index}:v]scale=${width}:${height}:force_original_aspect_ratio=decrease:flags=lanczos,` +
72
72
  `pad=${width}:${height}:(ow-iw)/2:(oh-ih)/2:color=black,` +
73
73
  `setsar=1,fps=30,format=yuv420p[v${index}]`);
74
74
  filters.push(`${framePaths.map((_frame, index) => `[v${index}]`).join("")}` +
75
75
  `concat=n=${framePaths.length}:v=1:a=0[outv]`);
76
- args.push("-filter_complex", filters.join(";"), "-map", "[outv]", "-c:v", "libvpx", "-deadline", "good", "-cpu-used", "4", "-crf", "28", "-b:v", "0", "-an", "-y", opts.outputPath);
76
+ args.push("-filter_complex", filters.join(";"), "-map", "[outv]", "-c:v", "libx264", "-preset", "medium", "-tune", "stillimage", "-crf", "14", "-profile:v", "main", "-movflags", "+faststart", "-an", "-y", opts.outputPath);
77
77
  const result = await runFf(ffmpeg, args, Math.max(120_000, durationSeconds * 10_000));
78
78
  if (result.code !== 0) {
79
79
  const detail = result.stderr.trim().slice(-1_000);
package/dist/setup.js ADDED
@@ -0,0 +1,203 @@
1
+ /**
2
+ * `clipy setup <agent>` — one command that wires Clipy into a coding agent.
3
+ *
4
+ * `agents install` writes the skill and deliberately leaves MCP alone. That
5
+ * split is right when a human is choosing, and wrong when an agent is following
6
+ * setup instructions: it turns "connect Clipy" into four commands across three
7
+ * docs. `setup` is the explicit one-shot form — skill + MCP + login, named so
8
+ * the wider blast radius is something the caller asked for rather than a side
9
+ * effect of installing a skill file.
10
+ *
11
+ * Home paths, environment signals, and subprocesses come from SetupEnv so the
12
+ * full matrix is testable against temporary directories.
13
+ */
14
+ import { join } from "node:path";
15
+ import { mcpSnippetFor, registerConfigMcpServer } from "./setupConfig.js";
16
+ import { MCP_ARGS, MCP_COMMAND, MCP_SERVER_NAME, } from "./setupTypes.js";
17
+ export { mcpSnippetFor } from "./setupConfig.js";
18
+ export { isSetupTarget, MCP_ARGS, MCP_COMMAND, MCP_SERVER_NAME, SETUP_TARGETS, } from "./setupTypes.js";
19
+ // ---------------------------------------------------------------------------
20
+ // Which agent are we in?
21
+ // ---------------------------------------------------------------------------
22
+ /**
23
+ * Best-effort detection from the host agent's own environment variables.
24
+ *
25
+ * Deliberately conservative: two different agents' signals firing at once means
26
+ * we are running nested (an agent that spawned another agent's CLI), and
27
+ * guessing there would install into the wrong home directory. Ambiguity returns
28
+ * undefined so the caller asks for an explicit target instead.
29
+ */
30
+ export function detectSetupTarget(env) {
31
+ const hits = new Set();
32
+ if (env.CLAUDECODE || env.CLAUDE_CODE_ENTRYPOINT)
33
+ hits.add("claude");
34
+ if (env.CODEX_HOME ||
35
+ env.CODEX_SANDBOX ||
36
+ env.CODEX_CI ||
37
+ env.CODEX_THREAD_ID ||
38
+ env.CODEX_INTERNAL_ORIGINATOR_OVERRIDE) {
39
+ hits.add("codex");
40
+ }
41
+ if (env.CURSOR_TRACE_ID || env.TERM_PROGRAM === "cursor")
42
+ hits.add("cursor");
43
+ if (env.OPENCODE || env.OPENCODE_BIN_PATH)
44
+ hits.add("opencode");
45
+ if (env.WINDSURF_USER_ID || env.TERM_PROGRAM === "windsurf")
46
+ hits.add("windsurf");
47
+ return hits.size === 1 ? [...hits][0] : undefined;
48
+ }
49
+ // ---------------------------------------------------------------------------
50
+ // Skills
51
+ // ---------------------------------------------------------------------------
52
+ /**
53
+ * Where each supported agent reads its global SKILL.md.
54
+ */
55
+ export function skillPathFor(target, env) {
56
+ switch (target) {
57
+ case "claude":
58
+ return join(env.home, ".claude", "skills", "clipy", "SKILL.md");
59
+ case "codex":
60
+ return join(env.env.CODEX_HOME?.trim() || join(env.home, ".codex"), "skills", "clipy", "SKILL.md");
61
+ case "cursor":
62
+ return join(env.home, ".cursor", "skills", "clipy", "SKILL.md");
63
+ case "windsurf":
64
+ return join(env.home, ".codeium", "windsurf", "skills", "clipy", "SKILL.md");
65
+ case "opencode": {
66
+ const base = env.env.XDG_CONFIG_HOME?.trim() || join(env.home, ".config");
67
+ return join(base, "opencode", "skills", "clipy", "SKILL.md");
68
+ }
69
+ }
70
+ }
71
+ // ---------------------------------------------------------------------------
72
+ // MCP registration
73
+ // ---------------------------------------------------------------------------
74
+ /** The agent's own MCP subcommand, when it has one that writes a global config. */
75
+ function agentCliCommand(target) {
76
+ switch (target) {
77
+ // `--scope user` is what makes Clipy show up in every project; the default
78
+ // `local` scope is why a server "disappears" in another repo.
79
+ case "claude":
80
+ return ["claude", "mcp", "add", "--scope", "user", MCP_SERVER_NAME, "--", MCP_COMMAND, ...MCP_ARGS];
81
+ case "codex":
82
+ return ["codex", "mcp", "add", MCP_SERVER_NAME, "--", MCP_COMMAND, ...MCP_ARGS];
83
+ default:
84
+ return null;
85
+ }
86
+ }
87
+ export async function registerMcpServer(target, env) {
88
+ const argv = agentCliCommand(target);
89
+ if (argv) {
90
+ const printable = argv.join(" ");
91
+ const result = await env.run(argv[0], argv.slice(1));
92
+ if (result.spawnError) {
93
+ return {
94
+ method: "manual",
95
+ path: null,
96
+ changed: false,
97
+ alreadyPresent: false,
98
+ command: printable,
99
+ reason: `the \`${argv[0]}\` command is not on PATH, so Clipy could not register the MCP server for you`,
100
+ };
101
+ }
102
+ const output = `${result.stdout}\n${result.stderr}`;
103
+ if (result.code !== 0) {
104
+ // Re-running setup is expected (a version bump, a second project), and an
105
+ // agent that treats "already there" as failure will loop on it.
106
+ if (/already exists|already configured/i.test(output)) {
107
+ const verified = await verifyAgentCliRegistration(target, env);
108
+ if (verified) {
109
+ return { method: "agent-cli", path: null, changed: false, alreadyPresent: true, command: printable };
110
+ }
111
+ return {
112
+ method: "manual",
113
+ path: null,
114
+ changed: false,
115
+ alreadyPresent: true,
116
+ command: replacementCommand(target, printable),
117
+ reason: "an existing Clipy MCP entry uses a different command or could not be verified",
118
+ };
119
+ }
120
+ return {
121
+ method: "manual",
122
+ path: null,
123
+ changed: false,
124
+ alreadyPresent: false,
125
+ command: printable,
126
+ reason: (result.stderr || result.stdout).trim().split("\n")[0] || `\`${printable}\` exited ${result.code}`,
127
+ };
128
+ }
129
+ return { method: "agent-cli", path: null, changed: true, alreadyPresent: false, command: printable };
130
+ }
131
+ const configured = registerConfigMcpServer(target, env);
132
+ if (configured)
133
+ return configured;
134
+ return {
135
+ method: "manual",
136
+ path: null,
137
+ changed: false,
138
+ alreadyPresent: false,
139
+ snippet: mcpSnippetFor(target, env),
140
+ reason: "this agent has no known MCP config location",
141
+ };
142
+ }
143
+ function replacementCommand(target, addCommand) {
144
+ const removeCommand = target === "claude"
145
+ ? `claude mcp remove ${MCP_SERVER_NAME} --scope user`
146
+ : `codex mcp remove ${MCP_SERVER_NAME}`;
147
+ return `${removeCommand} && ${addCommand}`;
148
+ }
149
+ async function verifyAgentCliRegistration(target, env) {
150
+ const args = target === "codex" ? ["mcp", "get", MCP_SERVER_NAME, "--json"] : ["mcp", "get", MCP_SERVER_NAME];
151
+ const result = await env.run(target, args);
152
+ if (result.code !== 0 || result.spawnError)
153
+ return false;
154
+ if (target === "claude") {
155
+ const scope = result.stdout.match(/^\s*Scope:\s*(.+)\s*$/im)?.[1]?.trim();
156
+ const transport = result.stdout.match(/^\s*Type:\s*(.+)\s*$/im)?.[1]?.trim();
157
+ const command = result.stdout.match(/^\s*Command:\s*(.+)\s*$/im)?.[1]?.trim();
158
+ const cliArgs = result.stdout.match(/^\s*Args:\s*(.+)\s*$/im)?.[1]?.trim().split(/\s+/);
159
+ return (scope?.startsWith("User config") === true &&
160
+ transport === "stdio" &&
161
+ command === MCP_COMMAND &&
162
+ JSON.stringify(cliArgs) === JSON.stringify(MCP_ARGS));
163
+ }
164
+ try {
165
+ return containsOfficialCommand(JSON.parse(result.stdout));
166
+ }
167
+ catch {
168
+ return false;
169
+ }
170
+ }
171
+ function containsOfficialCommand(value) {
172
+ if (!value || typeof value !== "object")
173
+ return false;
174
+ if (Array.isArray(value))
175
+ return value.some(containsOfficialCommand);
176
+ const record = value;
177
+ if (record.type === "stdio" &&
178
+ record.command === MCP_COMMAND &&
179
+ JSON.stringify(record.args) === JSON.stringify(MCP_ARGS)) {
180
+ return true;
181
+ }
182
+ return Object.values(record).some(containsOfficialCommand);
183
+ }
184
+ // ---------------------------------------------------------------------------
185
+ // Report
186
+ // ---------------------------------------------------------------------------
187
+ /** `/Users/x/.cursor/mcp.json` → `~/.cursor/mcp.json`, so the box stays readable. */
188
+ export function shortPath(path, home) {
189
+ return home && path.startsWith(`${home}/`) ? `~${path.slice(home.length)}` : path;
190
+ }
191
+ const BOX_MAX_WIDTH = 76;
192
+ /** Rows must be plain text -- an ANSI escape would break the alignment. */
193
+ function boxLine(text, width) {
194
+ const clipped = text.length > width ? `${text.slice(0, width - 1)}…` : text;
195
+ const pad = Math.max(0, width - clipped.length);
196
+ return `│ ${clipped}${" ".repeat(pad)} │`;
197
+ }
198
+ export function renderSetupBox(title, rows) {
199
+ const width = Math.min(BOX_MAX_WIDTH, Math.max(title.length, ...rows.map((r) => r.length), 44));
200
+ const top = `┌─ ${title} ${"─".repeat(Math.max(0, width - title.length + 1))}┐`;
201
+ const bottom = `└${"─".repeat(width + 4)}┘`;
202
+ return [top, ...rows.map((r) => boxLine(r, width)), bottom].join("\n");
203
+ }
@@ -0,0 +1,128 @@
1
+ import { chmodSync, closeSync, existsSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, writeFileSync, } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { MCP_ARGS, MCP_COMMAND, MCP_SERVER_NAME, } from "./setupTypes.js";
4
+ function configFilePlan(target, env) {
5
+ const stdio = { command: MCP_COMMAND, args: [...MCP_ARGS] };
6
+ switch (target) {
7
+ case "cursor":
8
+ return { candidates: [join(env.home, ".cursor", "mcp.json")], root: "mcpServers", entry: stdio };
9
+ case "windsurf":
10
+ return {
11
+ candidates: [join(env.home, ".codeium", "windsurf", "mcp_config.json")],
12
+ root: "mcpServers",
13
+ entry: stdio,
14
+ };
15
+ case "opencode": {
16
+ const base = env.env.XDG_CONFIG_HOME?.trim() || join(env.home, ".config");
17
+ return {
18
+ candidates: [join(base, "opencode", "opencode.json"), join(base, "opencode", "opencode.jsonc")],
19
+ root: "mcp",
20
+ entry: { type: "local", command: [MCP_COMMAND, ...MCP_ARGS], enabled: true },
21
+ };
22
+ }
23
+ default:
24
+ return null;
25
+ }
26
+ }
27
+ export function mcpSnippetFor(target, env) {
28
+ const plan = configFilePlan(target, env);
29
+ const root = plan?.root ?? "mcpServers";
30
+ const entry = plan?.entry ?? { command: MCP_COMMAND, args: [...MCP_ARGS] };
31
+ return JSON.stringify({ [root]: { [MCP_SERVER_NAME]: entry } }, null, 2);
32
+ }
33
+ function readJsonConfig(path) {
34
+ if (!existsSync(path))
35
+ return { parsed: null, raw: null, unparseable: false };
36
+ const file = lstatSync(path);
37
+ if (!file.isFile() || file.isSymbolicLink())
38
+ return { parsed: null, raw: null, unparseable: true };
39
+ try {
40
+ const raw = readFileSync(path, "utf8");
41
+ if (!raw.trim())
42
+ return { parsed: {}, raw, unparseable: false };
43
+ const value = JSON.parse(raw);
44
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
45
+ return { parsed: null, raw, unparseable: true };
46
+ }
47
+ return { parsed: value, raw, unparseable: false };
48
+ }
49
+ catch {
50
+ return { parsed: null, raw: null, unparseable: true };
51
+ }
52
+ }
53
+ function writeAtomicJson(path, value, previousRaw) {
54
+ mkdirSync(dirname(path), { recursive: true });
55
+ const currentMode = existsSync(path) ? lstatSync(path).mode & 0o777 : 0o600;
56
+ const mode = currentMode & 0o077 ? 0o600 : currentMode || 0o600;
57
+ const tempPath = `${path}.${process.pid}.${Date.now()}.tmp`;
58
+ let fd = null;
59
+ try {
60
+ fd = openSync(tempPath, "wx", 0o600);
61
+ writeFileSync(fd, `${JSON.stringify(value, null, 2)}\n`, "utf8");
62
+ fsyncSync(fd);
63
+ closeSync(fd);
64
+ fd = null;
65
+ chmodSync(tempPath, mode);
66
+ if (previousRaw === null) {
67
+ if (existsSync(path))
68
+ throw new Error("the config was created by another process during setup");
69
+ }
70
+ else if (readFileSync(path, "utf8") !== previousRaw) {
71
+ throw new Error("the config changed while setup was running");
72
+ }
73
+ renameSync(tempPath, path);
74
+ }
75
+ finally {
76
+ if (fd !== null)
77
+ closeSync(fd);
78
+ rmSync(tempPath, { force: true });
79
+ }
80
+ }
81
+ export function registerConfigMcpServer(target, env) {
82
+ const plan = configFilePlan(target, env);
83
+ if (!plan)
84
+ return null;
85
+ const path = plan.candidates.find((candidate) => existsSync(candidate)) ?? plan.candidates[0];
86
+ let config;
87
+ try {
88
+ config = readJsonConfig(path);
89
+ }
90
+ catch (error) {
91
+ return manualResult(target, env, path, error.message);
92
+ }
93
+ if (config.unparseable) {
94
+ return manualResult(target, env, path, `${path} is not plain JSON or is not a regular file`);
95
+ }
96
+ const parsed = config.parsed ?? {};
97
+ const existingRoot = parsed[plan.root];
98
+ if (existingRoot !== undefined && (!existingRoot || typeof existingRoot !== "object" || Array.isArray(existingRoot))) {
99
+ return manualResult(target, env, path, `the existing ${plan.root} value is not an object`);
100
+ }
101
+ const servers = (existingRoot ?? {});
102
+ if (JSON.stringify(servers[MCP_SERVER_NAME] ?? null) === JSON.stringify(plan.entry)) {
103
+ return { method: "config-file", path, changed: false, alreadyPresent: true };
104
+ }
105
+ const next = { ...parsed, [plan.root]: { ...servers, [MCP_SERVER_NAME]: plan.entry } };
106
+ try {
107
+ writeAtomicJson(path, next, config.raw);
108
+ }
109
+ catch (error) {
110
+ return manualResult(target, env, path, error.message);
111
+ }
112
+ return {
113
+ method: "config-file",
114
+ path,
115
+ changed: true,
116
+ alreadyPresent: MCP_SERVER_NAME in servers,
117
+ };
118
+ }
119
+ function manualResult(target, env, path, reason) {
120
+ return {
121
+ method: "manual",
122
+ path,
123
+ changed: false,
124
+ alreadyPresent: false,
125
+ snippet: mcpSnippetFor(target, env),
126
+ reason,
127
+ };
128
+ }
@@ -0,0 +1,7 @@
1
+ export const SETUP_TARGETS = ["claude", "codex", "cursor", "windsurf", "opencode"];
2
+ export function isSetupTarget(value) {
3
+ return !!value && SETUP_TARGETS.includes(value);
4
+ }
5
+ export const MCP_SERVER_NAME = "clipy";
6
+ export const MCP_COMMAND = "npx";
7
+ export const MCP_ARGS = ["-y", "@clipy/mcp@latest"];
package/dist/skill.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The bundled Clipy agent skill, installed by `clipy agents install <target>`
3
3
  * into the agent's skills directory (~/.claude/skills/clipy/SKILL.md etc.).
4
- * Covers BOTH halves: reading recordings (the public .md context document)
4
+ * Covers BOTH halves: reading recordings (the public .arec context document)
5
5
  * and making recordings (record / session / mark, headless or the real Mac
6
6
  * screen).
7
7
  *
@@ -10,12 +10,12 @@
10
10
  */
11
11
  export const CLIPY_SKILL_MD = `---
12
12
  name: clipy
13
- description: Read and create Clipy screen recordings, turn screenshots or tool-native video into proof, and turn any video into agent-readable context. Use when the user shares a clipy.online/video/<id> URL (watch, summarize, or act on a recording, bug report, or walkthrough), shares a YouTube URL or local video file as context/reference for a task ("implement what this video shows", "give me the context of this video" — import it with clipy context import), OR asks you to verify your own work and share proof through Clipy.
13
+ description: Read and create Clipy screen recordings, turn screenshots or tool-native video into proof, and turn any video into agent-readable context. Use when the user shares a clipy.online/video/<id> URL (watch, summarize, or act on a recording, bug report, or walkthrough), shares a YouTube URL, a Loom share link, or a local video file as context/reference for a task ("implement what this video shows", "give me the context of this video" — import it with clipy context import), OR asks you to verify your own work and share proof through Clipy.
14
14
  ---
15
15
 
16
16
  # Clipy — recordings you can read AND make
17
17
 
18
- Written for @clipy/cli + @clipy/mcp 0.12.0 (the two versions move in lockstep). If
18
+ Written for @clipy/cli + @clipy/mcp 0.13.1 (the two versions move in lockstep). If
19
19
  \`clipy --version\` reports older, upgrade first: \`npm i -g @clipy/cli@latest\`.
20
20
 
21
21
  Clipy (clipy.online) is the screen recorder built to be agent-readable. Every
@@ -36,8 +36,14 @@ for an MCP connection, trust its \`tools/list\` response.
36
36
 
37
37
  ## Reading a recording (no auth needed for public links)
38
38
 
39
+ RULE: every Clipy watch link has a machine-readable markdown twin at the same
40
+ URL with \`.arec\` appended. Whenever a Clipy video link appears ANYWHERE in your
41
+ task — the user's message, a PR description, an issue, a pasted chat — do not
42
+ try to watch the video or scrape the watch page: fetch the twin
43
+ (\`https://clipy.online/video/<id>.arec\`) and work from that.
44
+
39
45
  1. Given \`https://clipy.online/video/<id>\`, read the context document — either
40
- \`clipy context <id>\` or fetch \`https://clipy.online/video/<id>.md\`. Same
46
+ \`clipy context <id>\` or fetch \`https://clipy.online/video/<id>.arec\`. Same
41
47
  document: summary, action items, key-moment frames (with click coordinates
42
48
  and clicked-element labels when captured), and the full transcript.
43
49
  2. Still processing? The document says so; re-fetch in 30-60s, or block with
@@ -77,15 +83,20 @@ context hit with MCP \`read_context_document\`.
77
83
 
78
84
  ## Turning someone else's video into context (clipy context import)
79
85
 
80
- When the user hands you a YouTube URL or a local video file AS REFERENCE — "follow
81
- this tutorial", "here's the walkthrough", "this talk explains our approach" — you
82
- do not have to guess from the title. Convert it into a readable bundle:
86
+ When the user hands you a YouTube URL, a Loom share link, or a local video file
87
+ AS REFERENCE — "follow this tutorial", "here's the walkthrough", "this talk
88
+ explains our approach" — you do not have to guess from the title. Convert it into
89
+ a readable bundle:
83
90
 
84
91
  clipy context import https://youtube.com/watch?v=… --sync --json
92
+ clipy context import https://www.loom.com/share/<32-hex-id> --sync --json
85
93
  clipy context import ./demo.mov --transcript ./demo.vtt --sync --json
86
94
 
87
- Captions first, so it's fast: YouTube captions are fetched on your machine and no
88
- media is downloaded unless it turns out to be needed. Local files carry no
95
+ Captions first, so it's fast: YouTube captions and Loom transcripts are fetched on
96
+ your machine and no media is downloaded unless it turns out to be needed. Loom
97
+ needs no yt-dlp for this at all, so a yt-dlp warning in \`clipy doctor\` does not
98
+ block a Loom import. Roughly one Loom in six has no transcript recorded, and that
99
+ comes back as \`no_captions\` rather than an empty bundle. Local files carry no
89
100
  captions, so they need \`--transcript <.vtt|.srt|.json>\`.
90
101
 
91
102
  With \`--sync\`, the SERVER classifies the bundle — what kind of video it is, and
@@ -167,7 +178,9 @@ envelope says, including partial states.
167
178
  | code | what happened | what to do |
168
179
  |---|---|---|
169
180
  | \`invalid_url\` | the URL isn't a video Clipy can resolve | Re-read the URL with the user. Don't retry the same string. |
170
- | \`no_captions\` | the YouTube video has no captions in any language | Nothing to transcribe from. Tell the user; offer to import a local file with \`--transcript\`, or to proceed without the video. Not retryable. |
181
+ | \`no_captions\` | the source publishes no transcript: a YouTube video captioned in no language, or one of the ~16% of Looms with none recorded | Nothing to transcribe from. Tell the user; offer to re-run with \`--transcript\`, or to proceed without the video. Not retryable. |
182
+ | \`loom_unreachable\` | loom.com or its transcript CDN did not answer usefully | Usually transient. Re-run the SAME command once after a pause. If it repeats it is a network/proxy problem, not a bad link. |
183
+ | \`source_private\` | the video exists but is private or password-protected | Ask the user for a public share link, or for an exported copy to import with \`--transcript\`. Re-running the same URL cannot help. |
171
184
  | \`ytdlp_missing\` | yt-dlp couldn't be installed or resolved | \`clipy doctor --json\` names the path it tried. Fix: let it auto-install (it lands in \`~/.clipy/bin\`), or install manually — \`brew install yt-dlp\` / \`pipx install yt-dlp\`. Then re-run. |
172
185
  | \`ytdlp_download_403\` | YouTube refused the media download | **The CLI already retried internally.** If you still see this, the transcript half may have succeeded — read the envelope for what synced. Tell the user frames are pending and the document is usable without them. Do NOT loop. |
173
186
  | \`ffmpeg_missing\` | ffmpeg/ffprobe not found | \`brew install ffmpeg\` (macOS) · \`sudo apt install ffmpeg\` (Linux) · \`winget install Gyan.FFmpeg\`. Then re-run the SAME import command. |
@@ -229,8 +242,11 @@ Headless web capture also needs Playwright (kept out of the base install):
229
242
 
230
243
  npm i -g playwright && npx playwright install chromium
231
244
 
232
- Wiring up a coding agent? \`clipy agents install <claude|codex|cursor>\` does the
233
- browser login (if no key yet) and installs this skill.
245
+ Wiring up a coding agent? \`clipy setup <claude|codex|cursor|windsurf|opencode>\`
246
+ does the browser login (if no key yet), installs this skill, and registers the
247
+ Clipy MCP server in that agent's own config. \`clipy agents install <target>\` is
248
+ the skill-only form. Published instructions an agent can fetch and execute:
249
+ https://clipy.online/agent-setup/prompt.md
234
250
 
235
251
  ## Choose the proof path before recording
236
252
 
@@ -251,7 +267,7 @@ WHAT must be verified, and WHETHER the target depends on an existing login.
251
267
  real session. Prefer the current agent/browser tool's own WebM/MP4 or
252
268
  screenshots and hand them to \`clipy proof\`. For continuous native proof,
253
269
  use \`clipy sources --json\`, select the exact Chrome/app window, and record
254
- it with \`--source mac-screen --window <exact-id>\`.
270
+ its starting screen area with \`--source mac-screen --window <exact-id>\`.
255
271
  - **Interactive Windows/Linux desktop:** the Mac bridge is unavailable. Reuse
256
272
  the existing browser/computer-use tool's video or screenshots with
257
273
  \`clipy proof\`; otherwise use Playwright with an existing approved auth
@@ -293,7 +309,7 @@ For a request such as "review this UI PR and record every changed page":
293
309
  - If pages require different accounts, browser profiles, native apps, or privacy
294
310
  boundaries, make separate proof recordings. Do not weaken authentication or
295
311
  expose unrelated windows merely to force everything into one video.
296
- - Return a short coverage list beside the watch and \`.md\` URLs so the reviewer
312
+ - Return a short coverage list beside the watch and \`.arec\` URLs so the reviewer
297
313
  can see exactly which routes/states the recording proves.
298
314
 
299
315
  ## Universal proof — use the tool the agent already has
@@ -644,8 +660,8 @@ Clipy will NEVER bring a window or tab to the front for you. It cannot know whic
644
660
  tab/page/simulator you mean, and on --source mac-screen it may not be recording a
645
661
  browser at all. Focusing the right surface is YOUR job — do it before \`session start\`
646
662
  (e.g. activate the tab with your own tooling), then confirm with the reported title.
647
- Note the title is read at START time; if you switch tabs mid-recording the camera
648
- follows the window, not your driver.
663
+ Note the title and screen area are fixed at START time. Moving the window does not
664
+ move the recording, and anything entering that area is filmed.
649
665
  - On \`clipy record --source mac-screen\`, \`--for\` is capped at 1740s (the app
650
666
  auto-stops at 1800s).
651
667
  - If a human presses Stop inside the app during your session, \`session stop\` /
@@ -700,8 +716,8 @@ mic-free on the strength of the flag you passed.
700
716
  then \`clipy context <id>\` and confirm the transcript matches what you meant to
701
717
  show.
702
718
  - When you hand a recording back, give the user BOTH the share URL
703
- (\`clipy.online/video/<id>\`, the human page) AND the \`.md\` context URL
704
- (\`clipy.online/video/<id>.md\`, for their agents).
719
+ (\`clipy.online/video/<id>\`, the human page) AND the \`.arec\` context URL
720
+ (\`clipy.online/video/<id>.arec\`, for their agents).
705
721
 
706
722
  ## When record / session / --source mac-screen fails
707
723
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@clipy/cli",
3
- "version": "0.12.0",
4
- "description": "Command-line interface for Clipy — list, search, and read your screen recordings' transcripts, AI summaries, and key moments from the terminal.",
3
+ "version": "0.13.1",
4
+ "description": "Command-line interface for Clipy \u2014 list, search, and read your screen recordings' transcripts, AI summaries, and key moments from the terminal.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "publishConfig": {
@@ -38,13 +38,14 @@
38
38
  "build": "tsc",
39
39
  "prepublishOnly": "npm run build",
40
40
  "start": "node dist/index.js",
41
- "test:auth": "npm run build && node scripts/mock-auth-server.test.mjs && node scripts/doctor.test.mjs",
41
+ "test:auth": "npm run build && node scripts/mock-auth-server.test.mjs && node scripts/doctor.test.mjs && node scripts/open-url.test.mjs",
42
42
  "test:proof": "npm run build && node scripts/proof-frames.test.mjs",
43
+ "test:setup": "npm run build && node scripts/setup.test.mjs",
43
44
  "test:memory": "npm run build && node scripts/memory-search.test.mjs",
44
45
  "test:session": "npm run build && node scripts/auth-guard.test.mjs && node scripts/session-control.test.mjs",
45
- "test": "npm run test:auth && npm run test:session && node scripts/proof-frames.test.mjs && node scripts/memory-search.test.mjs && node scripts/context-sync.test.mjs && node scripts/context-frames.test.mjs && node scripts/context-youtube-transcript.test.mjs && node scripts/context-youtube-url-lang.test.mjs && node scripts/context-retry.test.mjs && node scripts/context-json-envelope.test.mjs && node scripts/context-ytdlp-update.test.mjs",
46
+ "test": "npm run test:auth && npm run test:session && node scripts/setup.test.mjs && node scripts/transcript-replace.test.mjs && node scripts/proof-frames.test.mjs && node scripts/memory-search.test.mjs && node scripts/context-sync.test.mjs && node scripts/context-frames.test.mjs && node scripts/context-youtube-transcript.test.mjs && node scripts/context-youtube-url-lang.test.mjs && node scripts/context-loom-url.test.mjs && node scripts/context-loom-import.test.mjs && node scripts/context-retry.test.mjs && node scripts/context-json-envelope.test.mjs && node scripts/context-ytdlp-update.test.mjs",
46
47
  "prebuild": "node scripts/sync-context-core.mjs",
47
- "test:context": "npm run build && node scripts/context-sync.test.mjs && node scripts/context-frames.test.mjs && node scripts/context-youtube-transcript.test.mjs && node scripts/context-youtube-url-lang.test.mjs && node scripts/context-retry.test.mjs && node scripts/context-json-envelope.test.mjs && node scripts/context-ytdlp-update.test.mjs"
48
+ "test:context": "npm run build && node scripts/context-sync.test.mjs && node scripts/context-frames.test.mjs && node scripts/context-youtube-transcript.test.mjs && node scripts/context-youtube-url-lang.test.mjs && node scripts/context-loom-url.test.mjs && node scripts/context-loom-import.test.mjs && node scripts/context-retry.test.mjs && node scripts/context-json-envelope.test.mjs && node scripts/context-ytdlp-update.test.mjs"
48
49
  },
49
50
  "devDependencies": {
50
51
  "@types/node": "^22.0.0",