director-cinematic 0.1.0 → 0.1.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.
package/README.md CHANGED
@@ -15,12 +15,25 @@ cd my-director
15
15
  claude
16
16
  ```
17
17
 
18
- Needs Node.js 24 and Claude Code. Episode editing also needs ffmpeg and capcut-cli; `init` checks your
19
- machine and tells you what is missing (`npx director-cinematic doctor` checks again).
18
+ Needs Node.js 24 and Claude Code. capcut-cli (pinned 0.34.0, for CapCut drafts) installs with the workspace.
19
+ Episode editing also needs ffmpeg (`brew install ffmpeg` on macOS); `init` checks your machine and tells you
20
+ what is missing (`npx director-cinematic doctor` checks again).
20
21
 
21
22
  Send a script in Claude Code. Director asks which Studio site you use, connects it, and asks you to open a
22
23
  new conversation and sign in with your own Studio account.
23
24
 
25
+ ## Music and sound effects (optional)
26
+
27
+ The sound stage uses Epidemic Sound with your own account. Create an MCP Server key in Epidemic Sound
28
+ (Account -> API keys; downloads need a paid plan), then in your workspace run:
29
+
30
+ ```bash
31
+ npm run sound:connect
32
+ ```
33
+
34
+ Paste the key when asked (it stays hidden). It is checked with Epidemic, stored only in
35
+ `~/.config/epidemic-sound/` on your machine, and never goes into a chat. Open a new conversation afterwards.
36
+
24
37
  ## Make it yours
25
38
 
26
39
  - `.agents/skills/*/SKILL.md` and their `references/`: how Director directs, reviews and edits.
package/bin.mjs CHANGED
@@ -17,8 +17,8 @@ function npmCi(cwd) {
17
17
  });
18
18
  }
19
19
 
20
- async function printDoctor() {
21
- const checks = await doctor();
20
+ async function printDoctor(workspace) {
21
+ const checks = await doctor({ workspace });
22
22
  for (const c of checks) say(`${c.ok ? 'ok ' : 'missing'} ${c.name}${c.found ? ` (${c.found})` : ''}${c.ok ? '' : `\n ${c.fix}`}`);
23
23
  return checks.every(c => c.ok);
24
24
  }
@@ -30,7 +30,7 @@ async function main() {
30
30
  say(`Installed Director ${result.version} (${result.files} files) in ${target}`);
31
31
  if (await npmCi(target) !== 0) say('npm ci failed; run it again inside the folder.');
32
32
  say('');
33
- await printDoctor();
33
+ await printDoctor(target);
34
34
  say(`\nNext: cd ${JSON.stringify(target)} && claude\nSend a script; Director asks which Studio site you use and connects it.`);
35
35
  say('Skills live in .agents/skills: edit them to your own style. "npx director-cinematic@latest update" keeps your edits.');
36
36
  return 0;
@@ -44,8 +44,8 @@ async function main() {
44
44
  if (r.dependenciesChanged && await npmCi(target) !== 0) say('npm ci failed; run it again inside the folder.');
45
45
  return 0;
46
46
  }
47
- if (command === 'doctor') return (await printDoctor()) ? 0 : 1;
48
- say('Usage: npx director-cinematic <command>\n init [folder] install a new Director workspace (default ./director-cinematic)\n update [folder] bring in the new base workflow without overwriting your edits\n doctor check Node.js, Claude Code, ffmpeg and capcut-cli');
47
+ if (command === 'doctor') return (await printDoctor(resolve(args[0] ?? '.'))) ? 0 : 1;
48
+ say('Usage: npx director-cinematic <command>\n init [folder] install a new Director workspace (default ./director-cinematic)\n update [folder] bring in the new base workflow without overwriting your edits\n doctor [folder] check Node.js, Claude Code, ffmpeg and the workspace capcut-cli');
49
49
  return command === 'help' ? 0 : 2;
50
50
  }
51
51
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "director-cinematic",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Director: an AI film-director workspace for Claude Code that drives a Waoowaoo Studio over MCP. One command installs the base workflow and skills, which you then edit to your own style.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -69,17 +69,13 @@ lint.
69
69
 
70
70
  **5b. Sound (music, SFX, ambience).** After the picture is built, read `references/sound-design.md`.
71
71
  - **Epidemic Sound access first.** The sounds come from the Epidemic Sound MCP (tools such as `SearchRecordings`,
72
- `SearchSoundEffects`, `EditRecording`, `DownloadRecording`). If those tools are not available in this session, stop the sound
73
- stage (the picture is done; nothing is lost) and ask the user, in their language, to add the key:
74
- 1. In Epidemic Sound: Account → API keys → create an MCP Server key (needs an active paid subscription to download).
75
- 2. Save it privately: create `~/.config/epidemic-sound/mcp.env` containing `export EPIDEMIC_SOUND_MCP_API_KEY="…"` and run
76
- `chmod 600` on it.
77
- 3. A header helper reads it at connect time (the Claude app started from the Dock does not read shell profiles, so an
78
- environment variable alone is not enough): `~/.config/epidemic-sound/headers.sh`, chmod 700, which sources that file and
79
- prints `{"Authorization":"Bearer <key>"}`. Register once:
80
- `claude mcp add-json -s user epidemic-sound '{"type":"http","url":"https://www.epidemicsound.com/a/mcp-service/mcp","headersHelper":"<home>/.config/epidemic-sound/headers.sh"}'`
81
- 4. Start a new session (tools load at session start), then ask again.
82
- Never ask the user to paste the key into the chat, and never print or store it.
72
+ `SearchSoundEffects`, `EditRecording`, `DownloadRecording`). If those tools are not available in this session, run
73
+ `npm run sound:status`. Stop the sound stage (the picture is done; nothing is lost) and ask the user, in their language:
74
+ - `EPIDEMIC_NOT_CONFIGURED`: to create an MCP Server key in Epidemic Sound (Account -> API keys; downloads need a paid plan),
75
+ then run `npm run sound:connect` in a terminal in this folder and paste the key there (it stays hidden). It checks the
76
+ key with Epidemic, saves it in a private file and registers the `epidemic-sound` server for Claude Code.
77
+ - `EPIDEMIC_CONFIGURED`: only to open a new conversation (tools load when a conversation starts).
78
+ Never ask for the key in the chat, never run `sound:connect` yourself, and never print or store the key.
83
79
  - **Spot from text** (EDL reasons, review notes, line emotions): write `sound/cue_sheet.json` in the episode folder, one cue per
84
80
  music, SFX or ambience event with `id`, `kind`, `at`, `dur` (episode clock), `reason`, and later `file`, `hasVocals` (music,
85
81
  from metadata), `source { provider: "epidemic", kind, id, title }`, optional `sourceIn`, `fadeIn`, `fadeOut`, `gainDb`.
@@ -1,5 +1,22 @@
1
1
  {
2
2
  "permissions": {
3
- "allow": ["mcp__director_cinematic"]
3
+ "allow": [
4
+ "mcp__director_cinematic",
5
+ "mcp__epidemic-sound__*",
6
+ "Bash(node tools/edit/build.mjs *)",
7
+ "Bash(node tools/edit/fetch.mjs *)",
8
+ "Bash(node tools/edit/frames.mjs *)",
9
+ "Bash(node tools/edit/listen.mjs *)",
10
+ "Bash(node tools/edit/probe.mjs *)",
11
+ "Bash(node tools/edit/render-check.mjs *)",
12
+ "Bash(node tools/edit/review.mjs *)",
13
+ "Bash(node tools/edit/sound.mjs *)",
14
+ "Bash(node tools/resolve-timeline.mjs *)",
15
+ "Bash(npm run studio:use *)",
16
+ "Bash(npm run doctor:claude)",
17
+ "Bash(npm run sound:status)",
18
+ "Bash(npm run check)",
19
+ "Edit(/workspace/**)"
20
+ ]
4
21
  }
5
22
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "files": {
3
- ".agents/skills/episode-edit/SKILL.md": "210172b1205410ab75f9869334d31c06d8846eb6a4aa3f2e2f59a824f33812a4",
3
+ ".agents/skills/episode-edit/SKILL.md": "eec53cb301e9fb524bea9f4b7fee2fac92a1e5f1024531940a08aeb1ca71a50c",
4
4
  ".agents/skills/episode-edit/references/ai-footage-triage.md": "982e8ff3656f11ab1033b1e7a0ac748dc548a679eccf5562c8f9f0ec28f50d24",
5
5
  ".agents/skills/episode-edit/references/cutting-craft.md": "6e4f33ff067ad95224dcddc549c3d9a1e329ff06b64eb6c6d3681a51c4c729b1",
6
6
  ".agents/skills/episode-edit/references/panel-repair.md": "9841871426c7d4ffcaae9ef9195af2aae963a3cd44ed686a7676f743262e3947",
@@ -16,7 +16,7 @@
16
16
  ".agents/skills/studio-lifecycle/references/studio-prompt-craft.md": "d1a974a6b2c4a385202e2127c4247276d2628af9c9870d5fd21f49e2d1ae788a",
17
17
  ".agents/skills/video-group-direction/SKILL.md": "d36d6b8bfc6adbd7111af75f54dc800d51a6fda8279f29cb2674b977c8ca080b",
18
18
  ".agents/skills/video-group-direction/references/h3-prompt-contract.md": "9d208f974ea1132f348f285a565528309181968cdbe826d6c98e42ab08aab304",
19
- ".claude/settings.json": "d358cf16be40854cb6d21f74afa4c420a89458da9b3bf921bcf9af54c5e338fa",
19
+ ".claude/settings.json": "50b1c4e738b633e243702543d6c044d688a3ed5ace1d5f60163cbde85dc417bb",
20
20
  ".codex/config.toml": "a1f4ccbc6d02607507038eeb0d12ba02b521b0e88f89fc9a275128c536e3419e",
21
21
  "AGENTS.md": "3312423cd5affec52e70374b9b86331783a92585c84bbb5e970f17b4c7ec9797",
22
22
  "CLAUDE.md": "e1b71ebd94cb741387cb2040f972b4aa68921827c58c603c137837e2892903dc",
@@ -34,14 +34,15 @@
34
34
  "docs/evidence/director-knowledge/source-receipts.json": "75e9acb1fbe1b7e94e680b893524629b71963d7181a5c8bf55dba792a489bc7e",
35
35
  "docs/evidence/episode-edit/capcut-render-test.md": "b612aa547d475aae89d584ce71fe8e9bf731392520f8ac897132e0390ffdb206",
36
36
  "docs/evidence/video-direction/2026-11-09-research.md": "79ab8b02dae5266f470ff144cecf8a608836fa9166bb9d6036622c955b78b8bb",
37
- "package-lock.json": "f2ac8dc90015013162e102088e633c116877ec4ae1661e1c28629ebe586c9525",
38
- "src/cli/main.mjs": "21cb79be76f6b7d601473ca492138839434b916dc4b8121b5a2f5f452df9e228",
37
+ "package-lock.json": "cb0e51a737c8bf2fa70d21541e67a8c87ba557cebc72bd3cb456c85170dc6942",
38
+ "src/cli/main.mjs": "cf70fe900a24acf55bfb5dfbbfd97306392335d84db20c2f35844981b67182d8",
39
39
  "src/director/direction-review.mjs": "f472e4d900e50a5ace4f0f6b77bfc5e695406ba9d8bb3821ff23e37d59a13fc5",
40
40
  "src/director/original-image-checkpoint.mjs": "8f8801cbaed6d49b85f836b48600134fba71e3bbbd945005c499567f4aaae31a",
41
41
  "src/director/original-image.mjs": "05281c55bcb82532b015750c2895c63e7b8ddae65dcb439cffcbebe80d4b1ea3",
42
42
  "src/director/scene-plan.mjs": "87b76362b158fbb1e8a72f821ca1be2dc8500c2d477e3d3ac69be10cdcc0853c",
43
43
  "src/director/studio-revision.mjs": "e5e197a88e7fb9dd0acce2f183cb5ab0d9b2661ef98b726415c7f9ab84c1af43",
44
44
  "src/director/workflow.mjs": "542ca2b7d52a2491190ff5c4ca69c285fa0dd9cc73d322697400efc52da28e9e",
45
+ "src/integrations/epidemic/connect.mjs": "f995f02cc83bcf9bd04294529909556b2e9b4e5ea0f94a5f030d2921150a6600",
45
46
  "src/integrations/waoowaoo/claude.mjs": "43ef01f49e93fb661a595dc33a275feb35a9cea03f43deee22c3a08df00e4262",
46
47
  "src/integrations/waoowaoo/config.mjs": "fa808324d25a5547da6aa7beb14da4a438ee4305ec1287cbbde87b2afc6b19cb",
47
48
  "src/integrations/waoowaoo/discovery.mjs": "fd6db93ddb9f6c72d80c7754b0d55a958278d2853c106385466b44bcb0d73e4c",
@@ -52,7 +53,7 @@
52
53
  "tools/edit/fetch.mjs": "1fd3693f3cfcce9fb719d40ca602cc285e9be2bb71161dcbeace1108f3111cca",
53
54
  "tools/edit/frames.mjs": "d2d655b2c92a325507f05ff53710f71ed09fb7a178b5ecf65e786fd2d3155dd8",
54
55
  "tools/edit/house-style.default.json": "6941bbfa5e2cd91836d5dfec497b97237454198851237a9bfee5c62634f18ad8",
55
- "tools/edit/lib.mjs": "f3f6a016d0b066c2a4a675c1a6956102f8618a68d41fcaa8e6fae566048a8afb",
56
+ "tools/edit/lib.mjs": "563589a5ddf81f8539f1f0d9d6efae2b23d3475aabf3659a01b28803b559cbd9",
56
57
  "tools/edit/listen.mjs": "7bf3ed781f63d994d5ad330f85b1b6f4eb9e163af6d42bdbfb740f3909d540e5",
57
58
  "tools/edit/probe.mjs": "e1b2caa4b8daa951b4cd83eacee6543499795478897a899fecef652e59b280ed",
58
59
  "tools/edit/project.mjs": "a1c2d3b1e57f06ecfdb2f3963c3ee3cbf048ab779fd0dab950c3d2168d458dbc",
@@ -64,7 +65,7 @@
64
65
  "tools/edit/sound.mjs": "583f1a033402cf75ecbd6ed40eba0deceab0f833708854e15f4f3642038fa4a7",
65
66
  "tools/resolve-timeline.mjs": "06aa14dd8c1eb7f3cd505216ef64bb7aa8b8bde221da022a55bb8493b649479b",
66
67
  "workspace/.gitkeep": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
67
- "package.json": "7bf9fc83344746df11cfd33819c50e772477ea8cfa52a8b576c0305ce9f1d334",
68
+ "package.json": "379f83c400dfe8d221bf4f8b8727be47075f4f11d2143ddef2c04c7776dcd5f6",
68
69
  ".gitignore": "2883ea30897e280ec234459b54acebf2d5586cf0f60945cb58d96a0ec1c835a3"
69
70
  },
70
71
  "links": {
@@ -72,5 +73,5 @@
72
73
  ".claude/skills/scene-direction": "../../.agents/skills/scene-direction",
73
74
  ".claude/skills/video-group-direction": "../../.agents/skills/video-group-direction"
74
75
  },
75
- "version": "0.1.0"
76
+ "version": "0.1.1"
76
77
  }
@@ -8,12 +8,26 @@
8
8
  "name": "director-studio",
9
9
  "version": "0.1.0",
10
10
  "dependencies": {
11
+ "capcut-cli": "0.34.0",
11
12
  "smol-toml": "1.9.1"
12
13
  },
13
14
  "engines": {
14
15
  "node": ">=24 <26"
15
16
  }
16
17
  },
18
+ "node_modules/capcut-cli": {
19
+ "version": "0.34.0",
20
+ "resolved": "https://registry.npmjs.org/capcut-cli/-/capcut-cli-0.34.0.tgz",
21
+ "integrity": "sha512-V2QducASUtwqx93jIpyzmAOe4ZyRB1EsZtep4Xh46rQGJ2Ndv/Z0KsKKZQMT/BBvaNjO0BQYLPearjqTh7Dziw==",
22
+ "license": "MIT",
23
+ "bin": {
24
+ "capcut": "dist/index.js",
25
+ "capcut-cli": "dist/index.js"
26
+ },
27
+ "engines": {
28
+ "node": ">=18"
29
+ }
30
+ },
17
31
  "node_modules/smol-toml": {
18
32
  "version": "1.9.1",
19
33
  "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.9.1.tgz",
@@ -10,11 +10,14 @@
10
10
  "doctor": "node src/cli/main.mjs doctor",
11
11
  "doctor:claude": "node src/cli/main.mjs doctor-claude",
12
12
  "studio:use": "node src/cli/main.mjs use-studio",
13
+ "sound:connect": "node src/cli/main.mjs sound-connect",
14
+ "sound:status": "node src/cli/main.mjs sound-status",
13
15
  "mcp:login": "node src/cli/main.mjs login",
14
16
  "test:mcp:live": "node src/cli/main.mjs smoke",
15
17
  "check": "node src/cli/main.mjs check"
16
18
  },
17
19
  "dependencies": {
20
+ "capcut-cli": "0.34.0",
18
21
  "smol-toml": "1.9.1"
19
22
  }
20
23
  }
@@ -2,6 +2,8 @@ import { fileURLToPath } from 'node:url';
2
2
  import { loadConnection } from '../integrations/waoowaoo/config.mjs';
3
3
  import { probeDiscovery } from '../integrations/waoowaoo/discovery.mjs';
4
4
  import { inspectNative, loginNative } from '../integrations/waoowaoo/native.mjs';
5
+ import { connectEpidemic, epidemicPaths, promptHidden, readRegistered } from '../integrations/epidemic/connect.mjs';
6
+ import { access } from 'node:fs/promises';
5
7
  import { checkProjectDescriptor, inspectClaude, readChosenStudio, studioEndpoint, chooseStudio } from '../integrations/waoowaoo/claude.mjs';
6
8
 
7
9
  const root = fileURLToPath(new URL('../..', import.meta.url));
@@ -24,6 +26,23 @@ async function useStudio(answer) {
24
26
  return 0;
25
27
  }
26
28
 
29
+ async function soundConnect() {
30
+ process.stdout.write('Epidemic Sound: Account -> API keys -> create an MCP Server key (downloads need a paid plan).\n');
31
+ const key = await promptHidden('Paste the key (it stays hidden) and press Enter: ');
32
+ const result = await connectEpidemic(key);
33
+ print({ ...result, next: 'Open a new conversation in this folder; the Epidemic Sound tools load when it starts.' });
34
+ return 0;
35
+ }
36
+
37
+ async function soundStatus() {
38
+ const registered = await readRegistered();
39
+ const keySaved = await access(epidemicPaths().env).then(() => true, () => false);
40
+ print({ state: registered && keySaved ? 'EPIDEMIC_CONFIGURED' : 'EPIDEMIC_NOT_CONFIGURED', registered: Boolean(registered), keySaved,
41
+ next: registered && keySaved ? 'If the tools are missing in this conversation, ask for a new one.'
42
+ : 'Ask the user to run npm run sound:connect in a terminal in this folder (the key is typed there, never in chat).' });
43
+ return registered && keySaved ? 0 : 1;
44
+ }
45
+
27
46
  async function doctorClaude() {
28
47
  await checkProjectDescriptor(root);
29
48
  const studio = await readChosenStudio();
@@ -41,13 +60,15 @@ async function doctorClaude() {
41
60
 
42
61
  async function main() {
43
62
  const valid = command === 'use-studio' ? extra.length === 1
44
- : ['check', 'doctor', 'doctor-claude', 'smoke', 'login'].includes(command) && extra.length === 0;
63
+ : ['check', 'doctor', 'doctor-claude', 'smoke', 'login', 'sound-connect', 'sound-status'].includes(command) && extra.length === 0;
45
64
  if (!valid) {
46
- process.stderr.write('Usage: node src/cli/main.mjs <check|doctor|doctor-claude|smoke|login|use-studio <web address>>\n');
65
+ process.stderr.write('Usage: node src/cli/main.mjs <check|doctor|doctor-claude|smoke|login|sound-connect|sound-status|use-studio <web address>>\n');
47
66
  return 2;
48
67
  }
49
68
  if (command === 'use-studio') return useStudio(extra[0]);
50
69
  if (command === 'doctor-claude') return doctorClaude();
70
+ if (command === 'sound-connect') return soundConnect();
71
+ if (command === 'sound-status') return soundStatus();
51
72
  const config = await loadConnection(root);
52
73
  if (command === 'check') {
53
74
  await checkProjectDescriptor(root);
@@ -80,7 +101,9 @@ async function main() {
80
101
 
81
102
  try { process.exitCode = await main(); }
82
103
  catch (error) {
83
- print({ state: ['CONFIG_MISSING', 'CONFIG_INVALID', 'CLAUDE_CONFIG_INVALID', 'CLAUDE_CONFIG_SHADOWS', 'STUDIO_ADDRESS_INVALID'].includes(error.code) ? error.code : 'COMMAND_FAILED',
84
- message: 'Check the Studio address, the project descriptor and the installed host CLI. No credentials were rewritten.' });
104
+ print({ state: ['CONFIG_MISSING', 'CONFIG_INVALID', 'CLAUDE_CONFIG_INVALID', 'CLAUDE_CONFIG_SHADOWS', 'STUDIO_ADDRESS_INVALID',
105
+ 'KEY_INVALID', 'KEY_REJECTED', 'NOT_A_TERMINAL', 'REGISTRATION_FAILED', 'CANCELLED'].includes(error.code) ? error.code : 'COMMAND_FAILED',
106
+ message: error.code?.startsWith?.('KEY_') || error.code === 'NOT_A_TERMINAL' ? error.message
107
+ : 'Check the Studio address, the project descriptor and the installed host CLI. No credentials were rewritten.' });
85
108
  process.exitCode = 1;
86
109
  }
@@ -0,0 +1,113 @@
1
+ import { chmod, mkdir, readFile, writeFile } from 'node:fs/promises';
2
+ import { homedir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ import { runCaptured } from '../waoowaoo/native.mjs';
5
+ import { claudeUserConfigPath } from '../waoowaoo/claude.mjs';
6
+
7
+ // Epidemic Sound access for the sound stage. Each user brings their own MCP Server key (their own
8
+ // subscription and licences). The key is typed in the terminal, stored only in a private file, and read
9
+ // at connect time by a header helper: the desktop app started from the Dock does not read shell profiles.
10
+ export const EPIDEMIC_SERVER = 'epidemic-sound';
11
+ export const EPIDEMIC_URL = 'https://www.epidemicsound.com/a/mcp-service/mcp';
12
+ const KEY_VAR = 'EPIDEMIC_SOUND_MCP_API_KEY';
13
+
14
+ export class EpidemicError extends Error {
15
+ constructor(code) {
16
+ super({
17
+ KEY_INVALID: 'That does not look like a key: paste the MCP Server key from Epidemic Sound, Account -> API keys.',
18
+ KEY_REJECTED: 'Epidemic Sound refused that key. Create a new MCP Server key and try again.',
19
+ NOT_A_TERMINAL: 'Run this in a terminal so the key can be typed privately: npm run sound:connect',
20
+ REGISTRATION_FAILED: 'Claude Code did not record the epidemic-sound server.',
21
+ }[code] ?? 'Epidemic Sound connection failed.');
22
+ this.code = code;
23
+ }
24
+ }
25
+
26
+ export function epidemicPaths(home = homedir()) {
27
+ const dir = join(home, '.config', 'epidemic-sound');
28
+ return { dir, env: join(dir, 'mcp.env'), helper: join(dir, 'headers.sh') };
29
+ }
30
+
31
+ // Keys are opaque tokens. Refuse only what cannot be one or would break the quoted env file.
32
+ export function validKey(value) {
33
+ const key = String(value ?? '').trim();
34
+ if (key.length < 8 || key.length > 4096 || /[\s'"`$\\]/.test(key)) throw new EpidemicError('KEY_INVALID');
35
+ return key;
36
+ }
37
+
38
+ export const helperScript = () => `#!/bin/sh
39
+ # Claude Code MCP headersHelper for epidemic-sound: prints the Authorization header as JSON from the private key file
40
+ # (chmod 600). Works for apps started from the Dock, which do not read shell profiles.
41
+ . "$HOME/.config/epidemic-sound/mcp.env" || exit 1
42
+ [ -n "$${KEY_VAR}" ] || exit 1
43
+ printf '{"Authorization":"Bearer %s"}\\n' "$${KEY_VAR}"
44
+ `;
45
+
46
+ // Only a definite auth refusal blocks; any other answer leaves the key saved and the result reported.
47
+ export async function probeKey(key, { fetchImpl = fetch, timeoutMs = 10000 } = {}) {
48
+ try {
49
+ const response = await fetchImpl(EPIDEMIC_URL, {
50
+ method: 'POST', signal: AbortSignal.timeout(timeoutMs),
51
+ headers: { Authorization: `Bearer ${key}`, 'Content-Type': 'application/json', Accept: 'application/json, text/event-stream' },
52
+ body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'initialize',
53
+ params: { protocolVersion: '2025-06-18', capabilities: {}, clientInfo: { name: 'director-cinematic', version: '1' } } }),
54
+ });
55
+ if (response.status === 401 || response.status === 403) return 'KEY_REJECTED';
56
+ return response.ok ? 'KEY_ACCEPTED' : 'KEY_UNVERIFIED';
57
+ } catch {
58
+ return 'KEY_UNVERIFIED';
59
+ }
60
+ }
61
+
62
+ export async function readRegistered({ env = process.env, read = readFile } = {}) {
63
+ try {
64
+ const entry = JSON.parse(await read(claudeUserConfigPath(env), 'utf8'))?.mcpServers?.[EPIDEMIC_SERVER];
65
+ return entry && typeof entry === 'object' ? { url: entry.url, helper: entry.headersHelper ?? null } : null;
66
+ } catch {
67
+ return null;
68
+ }
69
+ }
70
+
71
+ export async function connectEpidemic(rawKey, { home = homedir(), env = process.env, run = runCaptured, fetchImpl, read = readFile } = {}) {
72
+ const key = validKey(rawKey);
73
+ const probe = await probeKey(key, { fetchImpl });
74
+ if (probe === 'KEY_REJECTED') throw new EpidemicError('KEY_REJECTED');
75
+ const paths = epidemicPaths(home);
76
+ await mkdir(paths.dir, { recursive: true, mode: 0o700 });
77
+ await chmod(paths.dir, 0o700);
78
+ await writeFile(paths.env, `export ${KEY_VAR}='${key}'\n`, { mode: 0o600 });
79
+ await chmod(paths.env, 0o600);
80
+ await writeFile(paths.helper, helperScript(), { mode: 0o700 });
81
+ await chmod(paths.helper, 0o700);
82
+ const wanted = { type: 'http', url: EPIDEMIC_URL, headersHelper: paths.helper };
83
+ const current = await readRegistered({ env, read });
84
+ if (!current || current.url !== wanted.url || current.helper !== wanted.headersHelper) {
85
+ if (current) await run('claude', ['mcp', 'remove', '--scope', 'user', EPIDEMIC_SERVER], { env, timeout: 15000 });
86
+ await run('claude', ['mcp', 'add-json', '--scope', 'user', EPIDEMIC_SERVER, JSON.stringify(wanted)], { env, timeout: 15000 });
87
+ const after = await readRegistered({ env, read });
88
+ if (!after || after.url !== wanted.url || after.helper !== wanted.headersHelper) throw new EpidemicError('REGISTRATION_FAILED');
89
+ }
90
+ return { state: 'EPIDEMIC_CONNECTED', key: probe, keyFile: paths.env, registered: !current ? 'added' : 'kept-or-replaced' };
91
+ }
92
+
93
+ // Hidden terminal input: nothing typed is echoed, so the key never appears on screen or in a log.
94
+ export function promptHidden(question, { input = process.stdin, output = process.stdout } = {}) {
95
+ if (!input.isTTY) return Promise.reject(new EpidemicError('NOT_A_TERMINAL'));
96
+ return new Promise((resolve, reject) => {
97
+ let value = '';
98
+ output.write(question);
99
+ input.setRawMode(true);
100
+ input.resume();
101
+ input.setEncoding('utf8');
102
+ const done = (error) => { input.setRawMode(false); input.pause(); input.off('data', onData); output.write('\n'); error ? reject(error) : resolve(value); };
103
+ const onData = chunk => {
104
+ for (const ch of chunk) {
105
+ if (ch === '\r' || ch === '\n') return done();
106
+ if (ch === '\u0003') return done(new EpidemicError('CANCELLED'));
107
+ if (ch === '\u007f' || ch === '\b') value = value.slice(0, -1);
108
+ else if (ch >= ' ') value += ch;
109
+ }
110
+ };
111
+ input.on('data', onData);
112
+ });
113
+ }
@@ -4,8 +4,10 @@ import fs from 'node:fs'
4
4
  import os from 'node:os'
5
5
  import path from 'node:path'
6
6
 
7
- export const CAPCUT = process.env.CAPCUT_CLI || path.join(os.homedir(), '.local/capcut-cli/node_modules/.bin/capcut')
8
7
  export const HERE = path.dirname(new URL(import.meta.url).pathname)
8
+ // capcut-cli is a pinned workspace dependency (npm ci installs it): the edit rules were measured on 0.34.0.
9
+ // CAPCUT_CLI points at another build when someone needs one.
10
+ export const CAPCUT = process.env.CAPCUT_CLI || path.join(HERE, '../../node_modules/.bin/capcut')
9
11
 
10
12
  export const readJson = file => JSON.parse(fs.readFileSync(file, 'utf8'))
11
13
  export const writeJson = (file, value) => { fs.mkdirSync(path.dirname(file), { recursive: true }); fs.writeFileSync(file, JSON.stringify(value, null, 1) + '\n') }
package/workspace.mjs CHANGED
@@ -109,15 +109,15 @@ const versionOf = async (run, command, args) => {
109
109
  catch { return null; }
110
110
  };
111
111
 
112
- export async function doctor({ run = execute, env = process.env, home = env.HOME ?? '' } = {}) {
112
+ export async function doctor({ run = execute, env = process.env, workspace = process.cwd() } = {}) {
113
113
  const major = Number(process.versions.node.split('.')[0]);
114
- const capcut = env.CAPCUT_CLI || join(home, '.local/capcut-cli/node_modules/.bin/capcut');
114
+ const capcut = env.CAPCUT_CLI || join(workspace, 'node_modules/.bin/capcut');
115
115
  const checks = [
116
116
  { name: 'Node.js 24 or 25', ok: major >= 24 && major < 26, found: process.versions.node, fix: 'Install Node.js 24 (LTS) from https://nodejs.org' },
117
117
  { name: 'Claude Code', found: await versionOf(run, 'claude', ['--version']), fix: 'Install Claude Code: https://claude.com/claude-code' },
118
118
  { name: 'ffmpeg (episode edit)', found: await versionOf(run, 'ffmpeg', ['-version']), fix: 'brew install ffmpeg' },
119
119
  { name: 'capcut-cli (episode edit)', found: await versionOf(run, capcut, ['--version']),
120
- fix: 'npm install --prefix ~/.local/capcut-cli capcut-cli@0.34.0 (or set CAPCUT_CLI to its path)' },
120
+ fix: 'Run "npm ci" in the Director folder; it installs the pinned capcut-cli (or set CAPCUT_CLI to another build)' },
121
121
  ];
122
122
  for (const check of checks) if (check.ok === undefined) check.ok = check.found !== null;
123
123
  return checks;