clipbait 1.2.0 → 1.3.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.
Files changed (3) hide show
  1. package/README.md +5 -5
  2. package/index.js +88 -49
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -2,18 +2,18 @@
2
2
 
3
3
  Turn any video into short viral clips — and auto-clip live streams — from your terminal or an AI agent. Wraps the [Clipbait](https://clipbait.ai) API.
4
4
 
5
- ## Fastest start — wire it into Claude Code in one command
5
+ ## Fastest start — one command
6
6
  ```bash
7
- npx clipbait init <your_api_key> # get it at clipbait.ai → Me → Developers / API
7
+ npx clipbait@latest
8
8
  ```
9
- This saves your key, installs a **`/clipbait`** slash command, and connects the Clipbait MCP server to Claude Code. Then just type in Claude:
9
+ It opens Clipbait so you can grab your key, then installs a **`/clipbait`** slash command and connects the Clipbait MCP server to Claude Code. Then just type in Claude:
10
10
  ```
11
11
  /clipbait https://youtube.com/watch?v=...
12
12
  ```
13
13
 
14
14
  ## Or use it straight from the terminal
15
15
  ```bash
16
- npx clipbait login <your_api_key>
16
+ npx clipbait login <your_api_key> # get it at clipbait.ai → Me → Developers / API
17
17
  npx clipbait generate "https://youtube.com/watch?v=..." --aspect 9:16 --max 9
18
18
  npx clipbait status <jobId> # get finished clip URLs
19
19
  ```
@@ -21,7 +21,7 @@ npx clipbait status <jobId> # get finished clip URLs
21
21
  ## Commands
22
22
  | Command | Description |
23
23
  |---|---|
24
- | `clipbait init <apiKey>` | One-command Claude Code setup (`/clipbait` + MCP) |
24
+ | `clipbait` | One-command Claude Code setup (`/clipbait` + MCP) |
25
25
  | `clipbait login <apiKey>` | Save your API key (`~/.clipbait.json`) |
26
26
  | `clipbait generate <url> [--aspect 9:16] [--type talking_head] [--max 9]` | Generate clips |
27
27
  | `clipbait status <jobId>` | Check a job + get clip URLs |
package/index.js CHANGED
@@ -2,8 +2,9 @@
2
2
  // clipbait — CLI + agent tool. Generate viral clips from any video, from your
3
3
  // terminal or an AI agent. Zero dependencies (Node 18+ built-in fetch).
4
4
  //
5
- // Auth: `clipbait login <cbk_live_...>` (saved to ~/.clipbait.json) or the
6
- // CLIPBAIT_API_KEY env var. Get your key at clipbait.ai → Me → API key.
5
+ // Fastest start: npx clipbait (interactive: grabs your key, wires up Claude)
6
+ // Auth: `clipbait login <cbk_live_...>` or the CLIPBAIT_API_KEY env var.
7
+ // Get your key at clipbait.ai → Me → Developers / API.
7
8
 
8
9
  const fs = require("fs");
9
10
  const os = require("os");
@@ -11,6 +12,7 @@ const path = require("path");
11
12
 
12
13
  const CFG = path.join(os.homedir(), ".clipbait.json");
13
14
  const BASE = (process.env.CLIPBAIT_API_URL || "https://app.clipbait.ai/api").replace(/\/$/, "");
15
+ const KEY_PAGE = "https://app.clipbait.ai/me";
14
16
 
15
17
  function loadKey() {
16
18
  if (process.env.CLIPBAIT_API_KEY) return process.env.CLIPBAIT_API_KEY;
@@ -38,10 +40,85 @@ function parseFlags(args) {
38
40
  return { o, rest };
39
41
  }
40
42
 
43
+ function openBrowser(url) {
44
+ const { spawn } = require("child_process");
45
+ const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
46
+ const cmdArgs = process.platform === "win32" ? ["/c", "start", "", url] : [url];
47
+ try { spawn(cmd, cmdArgs, { stdio: "ignore", detached: true }).unref(); } catch { /* ignore */ }
48
+ }
49
+
50
+ function prompt(question) {
51
+ const readline = require("readline");
52
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
53
+ return new Promise((resolve) => rl.question(question, (a) => { rl.close(); resolve(a); }));
54
+ }
55
+
56
+ // The /clipbait Claude Code slash command. Installed by setup so users can type
57
+ // "/clipbait <url>" and let Claude drive the whole clip pipeline.
58
+ const SLASH_COMMAND = `---
59
+ description: Turn any video into viral clips with Clipbait
60
+ argument-hint: <video-url> [what you want]
61
+ ---
62
+ You have the \`clipbait\` MCP tools connected. The user's request: $ARGUMENTS
63
+
64
+ Do this, conversationally and fast:
65
+ 1. If there is no video URL in the request, ask for one (YouTube, Twitch VOD, Rumble, or Ganjing World). Otherwise don't ask for confirmation, just go.
66
+ 2. Read the intent and set params for \`generate_clips\`:
67
+ - vertical / shorts / tiktok / reels, or nothing specified => aspectRatio "9:16". landscape / widescreen / youtube => "16:9".
68
+ - if they mention a number of clips, use it as maxClips (1 to 20), otherwise 9.
69
+ 3. Call \`generate_clips\`, then poll \`get_job\` with the returned jobId every 30 seconds until status is "complete". Report progress between polls.
70
+ 4. When complete, list each finished clip as a numbered list: its hook and its URL.
71
+ 5. Then offer follow-ups and act on them by calling the tools again: regenerate at a different aspect ratio, pull more clips, or probe another video with \`probe_video\`.
72
+ `;
73
+
74
+ // Interactive one-command setup. Grabs the key (from arg / saved / by opening
75
+ // the browser and prompting), installs the /clipbait command, and connects the
76
+ // MCP server to Claude Code.
77
+ async function runSetup(providedKey) {
78
+ let key = providedKey && providedKey.startsWith("cbk_") ? providedKey : loadKey();
79
+
80
+ if (!key) {
81
+ console.log("\n⚡ Let's connect Clipbait to Claude.\n");
82
+ if (!process.stdin.isTTY) {
83
+ console.error(`Run this in a terminal, or pass your key: npx clipbait <cbk_live_...>\n Get your key at ${KEY_PAGE}`);
84
+ process.exit(1);
85
+ }
86
+ console.log(`Opening ${KEY_PAGE} so you can copy your API key…`);
87
+ openBrowser(KEY_PAGE);
88
+ key = (await prompt("\nPaste your API key (starts with cbk_) and press Enter:\n> ")).trim();
89
+ }
90
+
91
+ if (!key || !key.startsWith("cbk_")) {
92
+ console.error(`\nThat doesn't look like a Clipbait key (it should start with cbk_). Get yours at ${KEY_PAGE}`);
93
+ process.exit(1);
94
+ }
95
+
96
+ fs.writeFileSync(CFG, JSON.stringify({ apiKey: key }, null, 2));
97
+ const mcpUrl = "https://app.clipbait.ai/api/mcp/" + key;
98
+
99
+ // 1) Install the /clipbait slash command for Claude Code.
100
+ const cmdDir = path.join(os.homedir(), ".claude", "commands");
101
+ fs.mkdirSync(cmdDir, { recursive: true });
102
+ fs.writeFileSync(path.join(cmdDir, "clipbait.md"), SLASH_COMMAND);
103
+ console.log("✓ Installed the /clipbait command for Claude Code");
104
+
105
+ // 2) Register the MCP server with Claude Code (if the `claude` CLI exists).
106
+ const { spawnSync } = require("child_process");
107
+ const r = spawnSync("claude", ["mcp", "add", "--transport", "http", "clipbait", mcpUrl], { stdio: "ignore" });
108
+ if (!r.error && r.status === 0) {
109
+ console.log("✓ Connected the Clipbait MCP server to Claude Code");
110
+ } else {
111
+ console.log("• Couldn't auto-connect the MCP server (Claude Code CLI not found). Run this once:");
112
+ console.log(" claude mcp add --transport http clipbait " + mcpUrl);
113
+ }
114
+
115
+ console.log("\n🎬 Done! Restart Claude Code, then type:\n /clipbait https://youtube.com/watch?v=…\n");
116
+ }
117
+
41
118
  const HELP = `clipbait — AI clip generation
42
119
 
43
- clipbait init <apiKey> set up Claude Code: /clipbait command + MCP
44
- clipbait login <apiKey> save your API key
120
+ npx clipbait@latest set up Claude Code (recommended)
121
+ clipbait login <apiKey> just save your API key
45
122
  clipbait generate <url> [--aspect 9:16] [--type talking_head] [--max 9]
46
123
  clipbait status <jobId> check a job + get clip URLs
47
124
  clipbait jobs list recent jobs
@@ -53,6 +130,11 @@ Auth: CLIPBAIT_API_KEY env var or ~/.clipbait.json (via 'clipbait login').`;
53
130
  (async () => {
54
131
  const [cmd, ...args] = process.argv.slice(2);
55
132
  try {
133
+ // Bare `npx clipbait` → the one-command setup wizard (Remotion-style).
134
+ // Also accepts a pasted key as the first arg: `npx clipbait cbk_live_...`.
135
+ if (!cmd || (cmd && cmd.startsWith("cbk_"))) { await runSetup(cmd); return; }
136
+ if (cmd === "init" || cmd === "setup") { await runSetup(args[0]); return; }
137
+
56
138
  if (cmd === "login") {
57
139
  const key = args[0];
58
140
  if (!key) { console.error("Usage: clipbait login <cbk_live_...>"); process.exit(1); }
@@ -60,53 +142,10 @@ Auth: CLIPBAIT_API_KEY env var or ~/.clipbait.json (via 'clipbait login').`;
60
142
  console.log("✓ Saved API key to " + CFG);
61
143
  return;
62
144
  }
63
- if (cmd === "init") {
64
- // One-command Claude Code setup: save the key, install a /clipbait
65
- // slash command, and register the Clipbait MCP server.
66
- const key = args[0] && args[0].startsWith("cbk_") ? args[0] : loadKey();
67
- if (!key) {
68
- console.error("Usage: clipbait init <cbk_live_...>\n Get your key at clipbait.ai → Me → Developers / API");
69
- process.exit(1);
70
- }
71
- fs.writeFileSync(CFG, JSON.stringify({ apiKey: key }, null, 2));
72
- const mcpUrl = "https://app.clipbait.ai/api/mcp/" + key;
145
+ if (cmd === "help" || cmd === "--help" || cmd === "-h") { console.log(HELP); return; }
73
146
 
74
- // 1) Install the /clipbait slash command for Claude Code.
75
- const cmdDir = path.join(os.homedir(), ".claude", "commands");
76
- fs.mkdirSync(cmdDir, { recursive: true });
77
- const slash = `---
78
- description: Turn any video into viral clips with Clipbait
79
- argument-hint: <video-url> [what you want]
80
- ---
81
- You have the \`clipbait\` MCP tools connected. The user's request: $ARGUMENTS
82
-
83
- Do this, conversationally and fast:
84
- 1. If there is no video URL in the request, ask for one (YouTube, Twitch VOD, Rumble, or Ganjing World). Otherwise don't ask for confirmation, just go.
85
- 2. Read the intent and set params for \`generate_clips\`:
86
- - vertical / shorts / tiktok / reels, or nothing specified => aspectRatio "9:16". landscape / widescreen / youtube => "16:9".
87
- - if they mention a number of clips, use it as maxClips (1 to 20), otherwise 9.
88
- 3. Call \`generate_clips\`, then poll \`get_job\` with the returned jobId every 30 seconds until status is "complete". Report progress between polls.
89
- 4. When complete, list each finished clip as a numbered list: its hook and its URL.
90
- 5. Then offer follow-ups and act on them by calling the tools again: regenerate at a different aspect ratio, pull more clips, or probe another video with \`probe_video\`.
91
- `;
92
- fs.writeFileSync(path.join(cmdDir, "clipbait.md"), slash);
93
- console.log("✓ Installed /clipbait command → " + path.join(cmdDir, "clipbait.md"));
94
-
95
- // 2) Register the MCP server with Claude Code (if the `claude` CLI exists).
96
- const { spawnSync } = require("child_process");
97
- const r = spawnSync("claude", ["mcp", "add", "--transport", "http", "clipbait", mcpUrl], { stdio: "ignore" });
98
- if (!r.error && r.status === 0) {
99
- console.log("✓ Connected the Clipbait MCP server to Claude Code");
100
- } else {
101
- console.log("• Couldn't auto-connect the MCP server (Claude Code CLI not found). Run this once:");
102
- console.log(" claude mcp add --transport http clipbait " + mcpUrl);
103
- }
104
- console.log("\nDone. Restart Claude Code, then try:\n /clipbait https://youtube.com/watch?v=...");
105
- return;
106
- }
107
- if (!cmd || cmd === "help" || cmd === "--help" || cmd === "-h") { console.log(HELP); return; }
108
147
  if (!loadKey()) {
109
- console.error("No API key. Run: clipbait login <key> (get it at clipbait.ai Me → API key)");
148
+ console.error("No API key. Run: npx clipbait (get set up in one step)");
110
149
  process.exit(1);
111
150
  }
112
151
  const { o, rest } = parseFlags(args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clipbait",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "Clipbait CLI — turn any video into viral clips, and auto-clip live streams, from your terminal or AI agent.",
5
5
  "bin": { "clipbait": "index.js" },
6
6
  "type": "commonjs",