rushes 0.2.0
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/.claude-plugin/marketplace.json +14 -0
- package/.claude-plugin/plugin.json +10 -0
- package/.mcp.json +8 -0
- package/AGENTS.md +110 -0
- package/LICENSE +21 -0
- package/README.md +204 -0
- package/dist/cli/demo.js +339 -0
- package/dist/cli/doctor.js +307 -0
- package/dist/cli/index.js +11 -0
- package/dist/cli/main.js +469 -0
- package/dist/core/batches.js +58 -0
- package/dist/core/errors.js +37 -0
- package/dist/core/exportNotes.js +132 -0
- package/dist/core/ids.js +42 -0
- package/dist/core/media.js +128 -0
- package/dist/core/notes.js +117 -0
- package/dist/core/paths.js +17 -0
- package/dist/core/project.js +200 -0
- package/dist/core/schema.js +220 -0
- package/dist/core/script.js +113 -0
- package/dist/core/store.js +132 -0
- package/dist/core/tabs.js +24 -0
- package/dist/mcp/client.js +50 -0
- package/dist/mcp/ensure.js +69 -0
- package/dist/mcp/stdio.js +47 -0
- package/dist/mcp/tools.js +191 -0
- package/dist/server/app.js +710 -0
- package/dist/server/assets.js +234 -0
- package/dist/server/files.js +170 -0
- package/dist/server/lock.js +148 -0
- package/dist/server/loudness.js +331 -0
- package/dist/server/proxy.js +575 -0
- package/dist/server/reveal.js +71 -0
- package/dist/server/start.js +125 -0
- package/dist/server/watch.js +133 -0
- package/dist/setup/env.js +42 -0
- package/dist/setup/harnesses.js +93 -0
- package/dist/setup/setup.js +92 -0
- package/package.json +54 -0
- package/skills/rushes/SKILL.md +30 -0
- package/web-dist/assets/figtree-latin-400-normal-BD4aNku5.woff +0 -0
- package/web-dist/assets/figtree-latin-400-normal-g7Dtegnw.woff2 +0 -0
- package/web-dist/assets/figtree-latin-500-normal-BWnGEVsr.woff2 +0 -0
- package/web-dist/assets/figtree-latin-500-normal-B_yy1phn.woff +0 -0
- package/web-dist/assets/figtree-latin-600-normal-BM_oTo4n.woff +0 -0
- package/web-dist/assets/figtree-latin-600-normal-Cv_xCTDl.woff2 +0 -0
- package/web-dist/assets/figtree-latin-700-normal-BCCt2T1q.woff +0 -0
- package/web-dist/assets/figtree-latin-700-normal-th6qEP7c.woff2 +0 -0
- package/web-dist/assets/figtree-latin-ext-400-normal-CXAzuTZb.woff2 +0 -0
- package/web-dist/assets/figtree-latin-ext-400-normal-Gbh-3PTk.woff +0 -0
- package/web-dist/assets/figtree-latin-ext-500-normal-BOEJvrb_.woff +0 -0
- package/web-dist/assets/figtree-latin-ext-500-normal-Du0rIuHj.woff2 +0 -0
- package/web-dist/assets/figtree-latin-ext-600-normal-CQqsimlV.woff +0 -0
- package/web-dist/assets/figtree-latin-ext-600-normal-DJlfifZj.woff2 +0 -0
- package/web-dist/assets/figtree-latin-ext-700-normal-BoDi4KL2.woff +0 -0
- package/web-dist/assets/figtree-latin-ext-700-normal-CS4sQkGV.woff2 +0 -0
- package/web-dist/assets/index-BjDIT_wL.css +1 -0
- package/web-dist/assets/index-DF6Rl-Ac.js +3 -0
- package/web-dist/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
- package/web-dist/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
- package/web-dist/assets/jetbrains-mono-cyrillic-500-normal-DJqRU3vO.woff +0 -0
- package/web-dist/assets/jetbrains-mono-cyrillic-500-normal-DmUKJPL_.woff2 +0 -0
- package/web-dist/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
- package/web-dist/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
- package/web-dist/assets/jetbrains-mono-greek-500-normal-D7SFKleX.woff +0 -0
- package/web-dist/assets/jetbrains-mono-greek-500-normal-JpySY46c.woff2 +0 -0
- package/web-dist/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
- package/web-dist/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/web-dist/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- package/web-dist/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
- package/web-dist/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- package/web-dist/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
- package/web-dist/assets/jetbrains-mono-latin-ext-500-normal-Cut-4mMH.woff2 +0 -0
- package/web-dist/assets/jetbrains-mono-latin-ext-500-normal-ckzbgY84.woff +0 -0
- package/web-dist/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
- package/web-dist/assets/jetbrains-mono-vietnamese-500-normal-DNRqzVM1.woff +0 -0
- package/web-dist/index.html +14 -0
package/dist/cli/demo.js
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { mkdir, readdir, rm } from "node:fs/promises";
|
|
4
|
+
import { join, resolve } from "node:path";
|
|
5
|
+
import { addVariant, addVersion, setShots, shotAt } from "../core/project.js";
|
|
6
|
+
import { addNote } from "../core/notes.js";
|
|
7
|
+
import { setSections } from "../core/script.js";
|
|
8
|
+
import { toManifestPath } from "../core/paths.js";
|
|
9
|
+
import { Store } from "../core/store.js";
|
|
10
|
+
/** A `Runner` over `cmd`, via `child_process.spawn` with no shell. */
|
|
11
|
+
export function makeRunner(cmd) {
|
|
12
|
+
return (args) => new Promise((res) => {
|
|
13
|
+
let stdout = "";
|
|
14
|
+
let stderr = "";
|
|
15
|
+
let child;
|
|
16
|
+
try {
|
|
17
|
+
child = spawn(cmd, args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
res({ code: 1, stdout: "", stderr: "" });
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
child.stdout.on("data", (d) => (stdout += d.toString()));
|
|
24
|
+
child.stderr.on("data", (d) => (stderr += d.toString()));
|
|
25
|
+
child.on("error", () => res({ code: 1, stdout, stderr }));
|
|
26
|
+
child.on("close", (code) => res({ code: code ?? 1, stdout, stderr }));
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** The real ffmpeg and `say` runners. `main.ts` injects these (or `null` for `say`) into `makeDemo`. */
|
|
30
|
+
export const ffmpegRunner = makeRunner("ffmpeg");
|
|
31
|
+
export const sayRunner = makeRunner("say");
|
|
32
|
+
/** Whether macOS `say` actually works here: `say -v ?` runs and lists at least one voice. */
|
|
33
|
+
export async function sayAvailable(run) {
|
|
34
|
+
try {
|
|
35
|
+
const r = await run(["-v", "?"]);
|
|
36
|
+
return r.code === 0 && r.stdout.trim().length > 0;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const PRODUCT = "Lumen";
|
|
43
|
+
const DURATION = 30;
|
|
44
|
+
const FONT = "/System/Library/Fonts/Supplemental/Arial.ttf";
|
|
45
|
+
/** Last non-empty line of ffmpeg's stderr, for a short, readable failure message. */
|
|
46
|
+
function tail(s) {
|
|
47
|
+
const lines = s
|
|
48
|
+
.split(/\r?\n/)
|
|
49
|
+
.map((l) => l.trim())
|
|
50
|
+
.filter(Boolean);
|
|
51
|
+
return lines[lines.length - 1] ?? "ffmpeg gave no reason";
|
|
52
|
+
}
|
|
53
|
+
/** Refuses a non-empty folder. Otherwise returns whether `dir` already existed (empty) before this run, so a failure part-way through knows how much of it is safe to remove. */
|
|
54
|
+
async function checkFolder(dir) {
|
|
55
|
+
let names;
|
|
56
|
+
try {
|
|
57
|
+
names = await readdir(dir);
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
if (e.code === "ENOENT")
|
|
61
|
+
return false;
|
|
62
|
+
throw e;
|
|
63
|
+
}
|
|
64
|
+
if (names.length > 0)
|
|
65
|
+
throw new Error("That folder isn't empty. Choose a new one: rushes demo <folder>");
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Everything `makeDemo` can leave behind under `root`: the `.rushes` project folder and the
|
|
70
|
+
* generated `renders` and `audio` folders. Nothing else is ever created there.
|
|
71
|
+
*/
|
|
72
|
+
async function removeDemoContents(root) {
|
|
73
|
+
await Promise.all([".rushes", "renders", "audio"].map((name) => rm(join(root, name), { recursive: true, force: true })));
|
|
74
|
+
}
|
|
75
|
+
async function requireFfmpeg(ffmpeg) {
|
|
76
|
+
let ok;
|
|
77
|
+
try {
|
|
78
|
+
ok = (await ffmpeg(["-version"])).code === 0;
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
ok = false;
|
|
82
|
+
}
|
|
83
|
+
if (!ok)
|
|
84
|
+
throw new Error("The demo needs ffmpeg to make its media. Run rushes doctor for how to install it.");
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* How `drawtext` burns the timecode in: with `font` (a file) when it's on this machine, else with
|
|
88
|
+
* fontconfig's default font (`""`, no `fontfile`) when a one-frame probe shows that works, as it
|
|
89
|
+
* does on most Linux builds -- or `null` to skip the overlay entirely: this ffmpeg wasn't compiled
|
|
90
|
+
* with `drawtext`, or it can't find any font (both common on a minimal install). Never a reason to
|
|
91
|
+
* fail the demo.
|
|
92
|
+
*/
|
|
93
|
+
async function drawtextFont(ffmpeg, font) {
|
|
94
|
+
try {
|
|
95
|
+
const r = await ffmpeg(["-hide_banner", "-filters"]);
|
|
96
|
+
if (r.code !== 0 || !/\bdrawtext\b/.test(`${r.stdout}\n${r.stderr}`))
|
|
97
|
+
return null;
|
|
98
|
+
if (existsSync(font))
|
|
99
|
+
return font;
|
|
100
|
+
const probe = await ffmpeg(["-hide_banner", "-f", "lavfi", "-i", "color=size=64x64:duration=0.04", "-vf", "drawtext=text=0", "-frames:v", "1", "-f", "null", "-"]);
|
|
101
|
+
return probe.code === 0 ? "" : null;
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/** `font` is a file path, `""` for fontconfig's default, or `null` for no timecode. */
|
|
108
|
+
function videoFilter(font, hue) {
|
|
109
|
+
const parts = [];
|
|
110
|
+
if (hue !== null)
|
|
111
|
+
parts.push(`hue=h=${hue}`);
|
|
112
|
+
if (font !== null)
|
|
113
|
+
parts.push(`drawtext=${font ? `fontfile=${font}:` : ""}text='%{pts\\:hms}':fontcolor=white:fontsize=36:x=24:y=24:box=1:boxcolor=black@0.5:boxborderw=10`);
|
|
114
|
+
return parts.length ? ["-vf", parts.join(",")] : [];
|
|
115
|
+
}
|
|
116
|
+
/** A 30 s 1280×720 `testsrc2` cut, optionally hue-shifted, with a burnt-in timecode when `drawtext` is available. */
|
|
117
|
+
async function renderCut(ffmpeg, out, opts) {
|
|
118
|
+
const args = [
|
|
119
|
+
"-hide_banner", "-y",
|
|
120
|
+
"-f", "lavfi", "-i", `testsrc2=size=1280x720:rate=25:duration=${DURATION}`,
|
|
121
|
+
...videoFilter(opts.font, opts.hue),
|
|
122
|
+
"-c:v", "libx264", "-preset", "veryfast", "-crf", "28", "-pix_fmt", "yuv420p",
|
|
123
|
+
out,
|
|
124
|
+
];
|
|
125
|
+
const r = await ffmpeg(args);
|
|
126
|
+
if (r.code !== 0)
|
|
127
|
+
throw new Error(`Couldn't render ${out}: ${tail(r.stderr)}`);
|
|
128
|
+
}
|
|
129
|
+
/** A placeholder tone, used when `say` isn't available: a plain sine wave, clearly not a voice read. */
|
|
130
|
+
async function renderSineTone(ffmpeg, out, freq, seconds) {
|
|
131
|
+
const args = ["-hide_banner", "-y", "-f", "lavfi", "-i", `sine=frequency=${freq}:duration=${seconds}`, "-ar", "44100", "-ac", "1", out];
|
|
132
|
+
const r = await ffmpeg(args);
|
|
133
|
+
if (r.code !== 0)
|
|
134
|
+
throw new Error(`Couldn't render ${out}: ${tail(r.stderr)}`);
|
|
135
|
+
}
|
|
136
|
+
/** A system voice's read of `text`, via `say -v ... -o out.aiff`, then converted to WAV with ffmpeg. */
|
|
137
|
+
async function renderSayVoice(say, ffmpeg, outWav, opts) {
|
|
138
|
+
const aiff = outWav.replace(/\.wav$/, ".aiff");
|
|
139
|
+
const args = [];
|
|
140
|
+
if (opts.voice)
|
|
141
|
+
args.push("-v", opts.voice);
|
|
142
|
+
if (opts.rate)
|
|
143
|
+
args.push("-r", String(opts.rate));
|
|
144
|
+
args.push("-o", aiff, opts.text);
|
|
145
|
+
const said = await say(args);
|
|
146
|
+
if (said.code !== 0)
|
|
147
|
+
throw new Error(`"say" couldn't make ${aiff}: ${tail(said.stderr)}`);
|
|
148
|
+
const conv = await ffmpeg(["-hide_banner", "-y", "-i", aiff, "-ar", "44100", "-ac", "1", outWav]);
|
|
149
|
+
if (conv.code !== 0)
|
|
150
|
+
throw new Error(`Couldn't convert ${aiff}: ${tail(conv.stderr)}`);
|
|
151
|
+
await rm(aiff, { force: true });
|
|
152
|
+
}
|
|
153
|
+
/** The first two of `say -v ?`'s voices matching `preferred`, in order -- or `[null, null]` to fall back to the default voice for both. */
|
|
154
|
+
export function pickVoices(listing, preferred = ["Daniel", "Samantha"]) {
|
|
155
|
+
const names = new Set(listing
|
|
156
|
+
.split(/\r?\n/)
|
|
157
|
+
.map((l) => l.trim().split(/\s+/)[0])
|
|
158
|
+
.filter(Boolean));
|
|
159
|
+
const found = preferred.filter((v) => names.has(v));
|
|
160
|
+
if (found.length >= 2)
|
|
161
|
+
return [found[0], found[1]];
|
|
162
|
+
if (found.length === 1)
|
|
163
|
+
return [found[0], found[0]];
|
|
164
|
+
return [null, null];
|
|
165
|
+
}
|
|
166
|
+
async function pickSystemVoices(say) {
|
|
167
|
+
try {
|
|
168
|
+
const r = await say(["-v", "?"]);
|
|
169
|
+
return r.code === 0 ? pickVoices(r.stdout) : [null, null];
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return [null, null];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/** A sustained chord from sine partials, via ffmpeg's `aevalsrc`, optionally amplitude-pulsed. */
|
|
176
|
+
async function renderChord(ffmpeg, out, opts) {
|
|
177
|
+
const terms = opts.freqs.map((f) => `0.18*sin(2*PI*${f}*t)`).join("+");
|
|
178
|
+
const envelope = opts.pulseHz ? `*(0.55+0.45*sin(2*PI*${opts.pulseHz}*t))` : "";
|
|
179
|
+
const args = ["-hide_banner", "-y", "-f", "lavfi", "-i", `aevalsrc=(${terms})${envelope}:s=44100:d=${opts.seconds}`, "-ar", "44100", "-ac", "2", out];
|
|
180
|
+
const r = await ffmpeg(args);
|
|
181
|
+
if (r.code !== 0)
|
|
182
|
+
throw new Error(`Couldn't render ${out}: ${tail(r.stderr)}`);
|
|
183
|
+
}
|
|
184
|
+
/** Three short, band-passed, faded noise bursts at `times`, mixed over `totalSeconds` of silence -- the classic "whoosh" recipe. */
|
|
185
|
+
async function renderWhooshes(ffmpeg, out, times, totalSeconds) {
|
|
186
|
+
const burstDur = 0.8;
|
|
187
|
+
const inputs = times.flatMap(() => ["-f", "lavfi", "-i", `anoisesrc=color=pink:duration=${burstDur}:sample_rate=44100`]);
|
|
188
|
+
inputs.push("-f", "lavfi", "-i", `anullsrc=channel_layout=mono:sample_rate=44100:duration=${totalSeconds}`);
|
|
189
|
+
const chains = times.map((t, i) => {
|
|
190
|
+
const delayMs = Math.max(0, Math.round(t * 1000));
|
|
191
|
+
return `[${i}:a]highpass=f=300,lowpass=f=3500,afade=t=in:d=0.15,afade=t=out:st=${(burstDur - 0.2).toFixed(2)}:d=0.2,adelay=${delayMs}:all=1[w${i}]`;
|
|
192
|
+
});
|
|
193
|
+
const labels = `${times.map((_, i) => `[w${i}]`).join("")}[${times.length}:a]`;
|
|
194
|
+
const filter = `${chains.join(";")};${labels}amix=inputs=${times.length + 1}:normalize=0[outa]`;
|
|
195
|
+
const args = ["-hide_banner", "-y", ...inputs, "-filter_complex", filter, "-map", "[outa]", "-ac", "1", out];
|
|
196
|
+
const r = await ffmpeg(args);
|
|
197
|
+
if (r.code !== 0)
|
|
198
|
+
throw new Error(`Couldn't render ${out}: ${tail(r.stderr)}`);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Builds a ready-to-explore example project in `dir` (§19.2): a test-pattern film in two cuts with
|
|
202
|
+
* shots, a four-section script, two rounds of voice reads, two music beds, an SFX pass with cues,
|
|
203
|
+
* example notes on every stage, and picks set for music and round 1. Every file is generated here,
|
|
204
|
+
* with ffmpeg (and macOS `say`, when it's there) -- nothing is downloaded or shipped.
|
|
205
|
+
*
|
|
206
|
+
* Refuses, without writing anything, when `dir` exists and isn't empty, or when ffmpeg isn't
|
|
207
|
+
* available through `deps.ffmpeg`. A failure after that point -- say isn't playing along, or
|
|
208
|
+
* ffmpeg chokes on one of the renders -- undoes everything this run created (the whole folder,
|
|
209
|
+
* if it didn't exist before; just what's inside it, if it did) and rethrows with a one-line
|
|
210
|
+
* reason, so nothing a user runs twice ever looks like a half-built project.
|
|
211
|
+
*/
|
|
212
|
+
export async function makeDemo(dir, deps) {
|
|
213
|
+
const root = resolve(dir);
|
|
214
|
+
// Decided before anything is written: whether a failure part-way through should remove `root`
|
|
215
|
+
// itself (we created it) or only what we put inside it (it was already there, empty).
|
|
216
|
+
const existedBefore = await checkFolder(root);
|
|
217
|
+
await requireFfmpeg(deps.ffmpeg);
|
|
218
|
+
try {
|
|
219
|
+
const store = new Store(root);
|
|
220
|
+
await store.init(`${PRODUCT} launch demo`);
|
|
221
|
+
// The layout README and AGENTS recommend: renders/ for cuts, audio/<voiceover|music|sfx>/ for the rest.
|
|
222
|
+
const rendersDir = join(root, "renders");
|
|
223
|
+
const voiceDir = join(root, "audio", "voiceover");
|
|
224
|
+
const musicDir = join(root, "audio", "music");
|
|
225
|
+
const sfxDir = join(root, "audio", "sfx");
|
|
226
|
+
await Promise.all([rendersDir, voiceDir, musicDir, sfxDir].map((d) => mkdir(d, { recursive: true })));
|
|
227
|
+
const font = await drawtextFont(deps.ffmpeg, deps.font ?? FONT);
|
|
228
|
+
// 1. The picture: a 30 s test-pattern film in two cuts, v2 hue-shifted, with shots every 6 s.
|
|
229
|
+
const v1Abs = join(rendersDir, "lumen-launch_v1.mp4");
|
|
230
|
+
const v2Abs = join(rendersDir, "lumen-launch_v2.mp4");
|
|
231
|
+
await renderCut(deps.ffmpeg, v1Abs, { hue: null, font });
|
|
232
|
+
await renderCut(deps.ffmpeg, v2Abs, { hue: 100, font });
|
|
233
|
+
let videoId = "";
|
|
234
|
+
let pictureNoteShot = null;
|
|
235
|
+
const pictureNoteT = 10;
|
|
236
|
+
await store.update("project", (p) => {
|
|
237
|
+
const { video, version: v1 } = addVersion(p, { video: `${PRODUCT} launch`, file: toManifestPath(root, v1Abs), duration: DURATION, fps: 25, note: "First cut of the test pattern" }, deps.now);
|
|
238
|
+
videoId = video.id;
|
|
239
|
+
const cut = setShots(p, video.id, v1.id, [0, 6, 12, 18, 24].map((start, i) => ({ name: `Shot ${i + 1}`, start })));
|
|
240
|
+
// Stamped as the server stamps a note made in the dashboard (app.ts, POST /api/notes).
|
|
241
|
+
pictureNoteShot = shotAt(cut.shots, pictureNoteT);
|
|
242
|
+
addVersion(p, { video: videoId, file: toManifestPath(root, v2Abs), duration: DURATION, fps: 25, note: "Hue pass, for comparison" }, deps.now);
|
|
243
|
+
});
|
|
244
|
+
// 2. The script: four plain sections about the fictional product.
|
|
245
|
+
const sections = [
|
|
246
|
+
{ id: "s1", start: 0, end: 7.5, current: `${PRODUCT} opens on a blank timeline and a flashing cursor.` },
|
|
247
|
+
{ id: "s2", start: 7.5, end: 15, current: `Drop in a folder of clips, and ${PRODUCT} finds the best takes on its own.` },
|
|
248
|
+
{ id: "s3", start: 15, end: 22.5, current: "Notes, picks and a locked cut travel with the project, not a chat log." },
|
|
249
|
+
{ id: "s4", start: 22.5, end: 30, current: `${PRODUCT}: fewer rounds, and a cut everyone signed off on.` },
|
|
250
|
+
];
|
|
251
|
+
await store.update("script", (s) => {
|
|
252
|
+
setSections(s, sections, { replace: true });
|
|
253
|
+
});
|
|
254
|
+
// 3. Voice reads, two rounds: Round 1 compares two voices; Round 2 is one voice at a slower pace.
|
|
255
|
+
const scriptText = sections.map((s) => s.current).join(" ");
|
|
256
|
+
const hasSay = deps.say !== null;
|
|
257
|
+
const [voiceA, voiceB] = hasSay ? await pickSystemVoices(deps.say) : [null, null];
|
|
258
|
+
const round1AWav = join(voiceDir, "round-1-voice-a.wav");
|
|
259
|
+
const round1BWav = join(voiceDir, "round-1-voice-b.wav");
|
|
260
|
+
const round2Wav = join(voiceDir, "round-2-voice-a-slower.wav");
|
|
261
|
+
if (hasSay) {
|
|
262
|
+
await renderSayVoice(deps.say, deps.ffmpeg, round1AWav, { voice: voiceA, text: scriptText });
|
|
263
|
+
await renderSayVoice(deps.say, deps.ffmpeg, round1BWav, { voice: voiceB, text: scriptText });
|
|
264
|
+
await renderSayVoice(deps.say, deps.ffmpeg, round2Wav, { voice: voiceA, rate: 140, text: scriptText });
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
await renderSineTone(deps.ffmpeg, round1AWav, 440, 10);
|
|
268
|
+
await renderSineTone(deps.ffmpeg, round1BWav, 554, 10);
|
|
269
|
+
await renderSineTone(deps.ffmpeg, round2Wav, 440, 12);
|
|
270
|
+
}
|
|
271
|
+
// Short names for the note text; the read names spell out why there's no voice.
|
|
272
|
+
const shortA = hasSay ? "Voice A" : "Placeholder A";
|
|
273
|
+
const shortB = hasSay ? "Voice B" : "Placeholder B";
|
|
274
|
+
const voiceAName = hasSay ? shortA : `${shortA} (no text-to-speech on this machine)`;
|
|
275
|
+
const voiceBName = hasSay ? shortB : `${shortB} (no text-to-speech on this machine)`;
|
|
276
|
+
const placeholder = "A placeholder tone, not a read";
|
|
277
|
+
let round1LaneId = "";
|
|
278
|
+
let voiceAId = "";
|
|
279
|
+
await store.update("project", (p) => {
|
|
280
|
+
const { lane, variant } = addVariant(p, { stage: "voice", round: "Round 1 · Voices", name: voiceAName, file: toManifestPath(root, round1AWav), description: hasSay ? "The script at a natural pace" : placeholder });
|
|
281
|
+
round1LaneId = lane.id;
|
|
282
|
+
voiceAId = variant.id;
|
|
283
|
+
addVariant(p, { stage: "voice", round: "Round 1 · Voices", name: voiceBName, file: toManifestPath(root, round1BWav), description: hasSay ? "A second voice, same script and pace" : placeholder });
|
|
284
|
+
addVariant(p, { stage: "voice", round: "Round 2 · Voice A, pace", name: "Voice A · slower", file: toManifestPath(root, round2Wav), description: "Based on Voice A, slower" });
|
|
285
|
+
});
|
|
286
|
+
// 4. Music beds: two synthesised chords at different tempos.
|
|
287
|
+
const warmPadWav = join(musicDir, "warm-pad.wav");
|
|
288
|
+
const pulseWav = join(musicDir, "pulse.wav");
|
|
289
|
+
await renderChord(deps.ffmpeg, warmPadWav, { freqs: [196, 246.94, 293.66], seconds: 12 });
|
|
290
|
+
await renderChord(deps.ffmpeg, pulseWav, { freqs: [220, 277.18, 329.63], seconds: 12, pulseHz: 2.5 });
|
|
291
|
+
let musicVariantId = "";
|
|
292
|
+
await store.update("project", (p) => {
|
|
293
|
+
const { variant } = addVariant(p, { stage: "music", name: "Warm pad", file: toManifestPath(root, warmPadWav) });
|
|
294
|
+
musicVariantId = variant.id;
|
|
295
|
+
addVariant(p, { stage: "music", name: "Pulse", file: toManifestPath(root, pulseWav) });
|
|
296
|
+
});
|
|
297
|
+
// 5. One SFX pass, three whooshes with cues.
|
|
298
|
+
const sfxWav = join(sfxDir, "pass-a.wav");
|
|
299
|
+
const cueTimes = [1.5, 4.5, 7.5];
|
|
300
|
+
await renderWhooshes(deps.ffmpeg, sfxWav, cueTimes, 9);
|
|
301
|
+
await store.update("project", (p) => {
|
|
302
|
+
addVariant(p, {
|
|
303
|
+
stage: "sfx",
|
|
304
|
+
name: "Pass A",
|
|
305
|
+
file: toManifestPath(root, sfxWav),
|
|
306
|
+
cues: [
|
|
307
|
+
{ name: "Whoosh 1", t: cueTimes[0] },
|
|
308
|
+
{ name: "Whoosh 2", t: cueTimes[1] },
|
|
309
|
+
{ name: "Whoosh 3", t: cueTimes[2] },
|
|
310
|
+
],
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
// 6. Picks: music and round 1, with music's level set to -12 dB so Mix shows a level.
|
|
314
|
+
await store.update("picks", (picks) => {
|
|
315
|
+
picks.lanes.music = musicVariantId;
|
|
316
|
+
picks.lanes[round1LaneId] = voiceAId;
|
|
317
|
+
picks.levels.music = -12;
|
|
318
|
+
});
|
|
319
|
+
// 7. Example notes: a point on Picture, a whole note on a Round 1 read, a range note with "Fall"
|
|
320
|
+
// on Music, and a whole note on Mix.
|
|
321
|
+
const voiceNote = hasSay ? `${shortA} reads warmer than ${shortB}. Lean that way for launch.` : `${shortA} over ${shortB} for now. Swap in real reads before launch.`;
|
|
322
|
+
await store.update("notes", (notes) => {
|
|
323
|
+
addNote(notes, { stage: "picture", video: videoId, version: "v1", scope: "point", t: pictureNoteT, shot: pictureNoteShot, text: "Hold the opening frame a beat longer before the cut." }, deps.now);
|
|
324
|
+
addNote(notes, { stage: "voice", on: `${round1LaneId}/${voiceAId}`, scope: "whole", text: voiceNote }, deps.now);
|
|
325
|
+
addNote(notes, { stage: "music", on: `music/${musicVariantId}`, scope: "range", t: 6, tOut: 9, marks: [{ kind: "fall" }], text: "Let the pad fall away under the last line." }, deps.now);
|
|
326
|
+
addNote(notes, { stage: "mix", on: null, scope: "whole", text: "Check the whole mix against a phone speaker before sign-off." }, deps.now);
|
|
327
|
+
});
|
|
328
|
+
return { dir: root };
|
|
329
|
+
}
|
|
330
|
+
catch (e) {
|
|
331
|
+
// A failure here must never leave a half-built project looking like a real one. Only `root`
|
|
332
|
+
// itself is treated carefully: remove it whole when we created it, or just what we put inside
|
|
333
|
+
// it when it was already there (and, by `checkFolder` above, already empty) -- never anything
|
|
334
|
+
// we didn't create.
|
|
335
|
+
await (existedBefore ? removeDemoContents(root) : rm(root, { recursive: true, force: true }));
|
|
336
|
+
const reason = e instanceof Error ? e.message : String(e);
|
|
337
|
+
throw new Error(`The demo couldn't finish (${reason}). Nothing was left behind.`);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { access, readFile, statfs as nodeStatfs } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { RUSHES_DIR, Store } from "../core/store.js";
|
|
4
|
+
import { FILES } from "../core/schema.js";
|
|
5
|
+
import { harnesses, LEGACY_DETAIL, legacyMcpLaunches, mcpLaunch, mentionsLegacySource, mergeJson, mergeToml } from "../setup/harnesses.js";
|
|
6
|
+
import { realSetupEnv } from "../setup/env.js";
|
|
7
|
+
import { canonicalRoot } from "../server/lock.js";
|
|
8
|
+
import { hasFpsMode, parseFfmpegVersion } from "../server/proxy.js";
|
|
9
|
+
export function realDoctorEnv(cwd) {
|
|
10
|
+
return {
|
|
11
|
+
...realSetupEnv(),
|
|
12
|
+
nodeVersion: process.version,
|
|
13
|
+
cwd,
|
|
14
|
+
statfs: async (path) => {
|
|
15
|
+
try {
|
|
16
|
+
const s = await nodeStatfs(path);
|
|
17
|
+
return { free: s.bavail * s.bsize };
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const exists = (p) => access(p).then(() => true, () => false);
|
|
26
|
+
/** How long doctor waits on any one command (ffmpeg, ffprobe, `claude mcp get`) before saying it couldn't check. */
|
|
27
|
+
export const DOCTOR_EXEC_TIMEOUT_MS = 10_000;
|
|
28
|
+
/** "v22.12.0" -> {major: 22, minor: 12}. Null for anything that doesn't start with a version. */
|
|
29
|
+
function parseNodeVersion(v) {
|
|
30
|
+
const m = /^v?(\d+)\.(\d+)/.exec(v);
|
|
31
|
+
return m ? { major: Number(m[1]), minor: Number(m[2]) } : null;
|
|
32
|
+
}
|
|
33
|
+
/** Matches package.json's engines field exactly: "^20.19.0 || >=22.12.0" (21.x is not supported). */
|
|
34
|
+
function nodeSupported(major, minor) {
|
|
35
|
+
return (major === 20 && minor >= 19) || major > 22 || (major === 22 && minor >= 12);
|
|
36
|
+
}
|
|
37
|
+
function nodeCheck(env) {
|
|
38
|
+
const v = parseNodeVersion(env.nodeVersion);
|
|
39
|
+
const ok = v !== null && nodeSupported(v.major, v.minor);
|
|
40
|
+
return {
|
|
41
|
+
id: "node",
|
|
42
|
+
label: "Node.js",
|
|
43
|
+
ok,
|
|
44
|
+
required: true,
|
|
45
|
+
detail: ok ? `${env.nodeVersion} is supported.` : `${env.nodeVersion} is too old. Rushes needs Node 20.19 or newer (or 22.12+ on the 22 line).`,
|
|
46
|
+
fix: ok ? undefined : "Install a current Node LTS: https://nodejs.org, or with nvm: nvm install --lts",
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** Plain install instructions by platform (global constraint: ffmpeg degrades gracefully, with a plain message). */
|
|
50
|
+
const FFMPEG_INSTALL = {
|
|
51
|
+
darwin: "brew install ffmpeg",
|
|
52
|
+
win32: "winget install Gyan.FFmpeg",
|
|
53
|
+
linux: "sudo apt install ffmpeg, or your distribution's package manager",
|
|
54
|
+
};
|
|
55
|
+
function installFix(platform) {
|
|
56
|
+
return FFMPEG_INSTALL[platform] ?? FFMPEG_INSTALL.linux;
|
|
57
|
+
}
|
|
58
|
+
async function ffmpegCheck(env) {
|
|
59
|
+
if (!(await env.which("ffmpeg"))) {
|
|
60
|
+
return {
|
|
61
|
+
id: "ffmpeg",
|
|
62
|
+
label: "ffmpeg",
|
|
63
|
+
ok: false,
|
|
64
|
+
required: false,
|
|
65
|
+
detail: "ffmpeg isn't on PATH. Proxies and full-quality frame grabs need it.",
|
|
66
|
+
fix: installFix(env.platform),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
let out = "";
|
|
70
|
+
try {
|
|
71
|
+
out = (await env.exec("ffmpeg", ["-version"], env.cwd, { timeout: DOCTOR_EXEC_TIMEOUT_MS })).out;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
out = "";
|
|
75
|
+
}
|
|
76
|
+
const version = parseFfmpegVersion(out);
|
|
77
|
+
if ((await hasLibx264(env)) === false) {
|
|
78
|
+
return {
|
|
79
|
+
id: "ffmpeg",
|
|
80
|
+
label: "ffmpeg",
|
|
81
|
+
ok: false,
|
|
82
|
+
required: false,
|
|
83
|
+
detail: `${version ? `ffmpeg ${version.major}.${version.minor}` : "ffmpeg"} is on PATH, but it was built without libx264, which proxies and the demo encode with.`,
|
|
84
|
+
fix: "Install an ffmpeg build that includes libx264 (on Fedora, RPM Fusion's ffmpeg rather than ffmpeg-free).",
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
// Controller ruling: ffmpeg below 5.1 still works (-vsync stands in for -fps_mode), so this is
|
|
88
|
+
// a warning, not a failure.
|
|
89
|
+
if (version && !hasFpsMode(version)) {
|
|
90
|
+
return {
|
|
91
|
+
id: "ffmpeg",
|
|
92
|
+
label: "ffmpeg",
|
|
93
|
+
ok: true,
|
|
94
|
+
required: false,
|
|
95
|
+
detail: `ffmpeg ${version.major}.${version.minor} works, but proxies use an older frame-rate option. Updating to 5.1 or newer is recommended.`,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
id: "ffmpeg",
|
|
100
|
+
label: "ffmpeg",
|
|
101
|
+
ok: true,
|
|
102
|
+
required: false,
|
|
103
|
+
detail: version ? `ffmpeg ${version.major}.${version.minor} is on PATH.` : "ffmpeg is on PATH.",
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Whether this ffmpeg can encode with libx264, which proxies and the demo use: some distribution
|
|
108
|
+
* builds (Fedora's ffmpeg-free, say) leave it out. Null when the encoder list couldn't be read --
|
|
109
|
+
* never reported as missing on a guess.
|
|
110
|
+
*/
|
|
111
|
+
async function hasLibx264(env) {
|
|
112
|
+
try {
|
|
113
|
+
const r = await env.exec("ffmpeg", ["-hide_banner", "-encoders"], env.cwd, { timeout: DOCTOR_EXEC_TIMEOUT_MS });
|
|
114
|
+
if (r.code !== 0 || !/Encoders:/.test(r.out))
|
|
115
|
+
return null;
|
|
116
|
+
return /\blibx264\b/.test(r.out);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/** "ffprobe version 6.1.1 Copyright ..." -> {major: 6, minor: 1}. Generic over the tool name, unlike parseFfmpegVersion. */
|
|
123
|
+
function parseToolVersion(text) {
|
|
124
|
+
const m = /version n?(\d+)\.(\d+)/.exec(text);
|
|
125
|
+
return m ? { major: Number(m[1]), minor: Number(m[2]) } : null;
|
|
126
|
+
}
|
|
127
|
+
async function ffprobeCheck(env) {
|
|
128
|
+
if (!(await env.which("ffprobe"))) {
|
|
129
|
+
return {
|
|
130
|
+
id: "ffprobe",
|
|
131
|
+
label: "ffprobe",
|
|
132
|
+
ok: false,
|
|
133
|
+
required: false,
|
|
134
|
+
detail: "ffprobe isn't on PATH. It ships with ffmpeg.",
|
|
135
|
+
fix: installFix(env.platform),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
let out = "";
|
|
139
|
+
try {
|
|
140
|
+
out = (await env.exec("ffprobe", ["-version"], env.cwd, { timeout: DOCTOR_EXEC_TIMEOUT_MS })).out;
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
out = "";
|
|
144
|
+
}
|
|
145
|
+
const version = parseToolVersion(out);
|
|
146
|
+
return { id: "ffprobe", label: "ffprobe", ok: true, required: false, detail: version ? `ffprobe ${version.major}.${version.minor} is on PATH.` : "ffprobe is on PATH." };
|
|
147
|
+
}
|
|
148
|
+
/** Is this harness installed at all (its marker folder exists, or its CLI is on PATH)? Mirrors setup.ts's own check, read-only. */
|
|
149
|
+
async function installed(h, env) {
|
|
150
|
+
return (await exists(h.marker)) || (h.bin ? await env.which(h.bin) : false);
|
|
151
|
+
}
|
|
152
|
+
/** Whether `h` has the Rushes MCP server registered, without changing anything -- reuses setup's own mergers as a dry-run diff. */
|
|
153
|
+
async function harnessCheck(h, env) {
|
|
154
|
+
const base = { id: `agent:${h.id}`, label: h.name, required: false };
|
|
155
|
+
if (h.kind === "claude-cli") {
|
|
156
|
+
if (!(await env.which("claude"))) {
|
|
157
|
+
return { ...base, ok: false, detail: "the claude command isn't on PATH, so registration can't be checked.", fix: `Install Claude Code, then run: rushes setup --only ${h.id}` };
|
|
158
|
+
}
|
|
159
|
+
// Run from home, like setup does, so a project's own .mcp.json can't make it look registered.
|
|
160
|
+
// With a time limit and no stdin: a slow claude (it may start the MCP server to check it) or
|
|
161
|
+
// one waiting on input must never stall doctor.
|
|
162
|
+
const got = await env.exec("claude", ["mcp", "get", "rushes"], env.home, { timeout: DOCTOR_EXEC_TIMEOUT_MS });
|
|
163
|
+
if (got.timedOut) {
|
|
164
|
+
return { ...base, ok: false, unknown: true, detail: `couldn't check: claude mcp get rushes didn't answer within ${DOCTOR_EXEC_TIMEOUT_MS / 1000} s.`, fix: "Run claude mcp get rushes yourself to check" };
|
|
165
|
+
}
|
|
166
|
+
if (got.code !== 0)
|
|
167
|
+
return { ...base, ok: false, detail: "the Rushes MCP server isn't registered.", fix: `rushes setup --only ${h.id}` };
|
|
168
|
+
const legacy = mentionsLegacySource(got.out);
|
|
169
|
+
return { ...base, ok: true, detail: legacy ? LEGACY_DETAIL : "the Rushes MCP server is registered." };
|
|
170
|
+
}
|
|
171
|
+
const path = h.config;
|
|
172
|
+
const text = await readFile(path, "utf8").catch(() => null);
|
|
173
|
+
try {
|
|
174
|
+
const launch = mcpLaunch(env.platform);
|
|
175
|
+
const { changed } = h.kind === "toml" ? mergeToml(text, launch) : mergeJson(text, launch);
|
|
176
|
+
if (!changed)
|
|
177
|
+
return { ...base, ok: true, detail: "the Rushes MCP server is registered." };
|
|
178
|
+
// Not a match for the current (npm) launch -- but a registration written before the publish,
|
|
179
|
+
// still pointed at the GitHub source, counts as Rushes too.
|
|
180
|
+
const legacy = legacyMcpLaunches(env.platform).some((l) => !(h.kind === "toml" ? mergeToml(text, l) : mergeJson(text, l)).changed);
|
|
181
|
+
if (legacy)
|
|
182
|
+
return { ...base, ok: true, detail: LEGACY_DETAIL };
|
|
183
|
+
return { ...base, ok: false, detail: "the Rushes MCP server isn't registered.", fix: `rushes setup --only ${h.id}` };
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
return { ...base, ok: false, detail: `${path} exists but isn't valid, so registration can't be checked.`, fix: `Fix ${path}, then run: rushes setup --only ${h.id}` };
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Whether a Rushes server is running for this folder: a health request to its port, checked
|
|
191
|
+
* against this project's own canonical root (the same check `isRushesFor` in server/lock.ts
|
|
192
|
+
* makes), falling back to a pid check when nothing answers. A server answering for a *different*
|
|
193
|
+
* project is reported as a failure -- a stale server.json left behind when the project moved or
|
|
194
|
+
* its folder was reused -- everything else here is informational.
|
|
195
|
+
*/
|
|
196
|
+
async function serverCheck(cwd) {
|
|
197
|
+
const base = { id: "server", label: "Rushes server", required: false };
|
|
198
|
+
let lock = null;
|
|
199
|
+
try {
|
|
200
|
+
lock = JSON.parse(await readFile(join(cwd, RUSHES_DIR, "server.json"), "utf8"));
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
lock = null;
|
|
204
|
+
}
|
|
205
|
+
if (!lock || typeof lock.port !== "number" || typeof lock.pid !== "number") {
|
|
206
|
+
return { ...base, ok: true, detail: "No server is running for this folder." };
|
|
207
|
+
}
|
|
208
|
+
const { port, pid } = lock;
|
|
209
|
+
const root = await canonicalRoot(cwd);
|
|
210
|
+
let health = null;
|
|
211
|
+
try {
|
|
212
|
+
const res = await fetch(`http://127.0.0.1:${port}/api/health`, { signal: AbortSignal.timeout(800) });
|
|
213
|
+
if (res.ok)
|
|
214
|
+
health = (await res.json());
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
health = null; // The port didn't answer in time; fall back to a pid check below.
|
|
218
|
+
}
|
|
219
|
+
if (health?.app === "rushes") {
|
|
220
|
+
if (health.root !== root) {
|
|
221
|
+
return {
|
|
222
|
+
...base,
|
|
223
|
+
ok: false,
|
|
224
|
+
detail: `server.json points at another project's server (port ${port}).`,
|
|
225
|
+
fix: "Run rushes stop here, then rushes open",
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
return { ...base, ok: true, detail: `running on port ${port}${health.id ? `, project ${health.id}` : ""}.` };
|
|
229
|
+
}
|
|
230
|
+
let alive = false;
|
|
231
|
+
try {
|
|
232
|
+
process.kill(pid, 0);
|
|
233
|
+
alive = true;
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
alive = false;
|
|
237
|
+
}
|
|
238
|
+
return { ...base, ok: true, detail: alive ? `running on port ${port}.` : `not running (a stale lock names pid ${pid}; it clears on the next start).` };
|
|
239
|
+
}
|
|
240
|
+
/** Free space where proxies live, only reported when a proxies/ folder exists. */
|
|
241
|
+
async function diskSpaceCheck(env) {
|
|
242
|
+
const dir = join(env.cwd, "proxies");
|
|
243
|
+
if (!(await exists(dir)))
|
|
244
|
+
return null;
|
|
245
|
+
const info = await env.statfs(dir);
|
|
246
|
+
if (!info)
|
|
247
|
+
return null;
|
|
248
|
+
const gb = info.free / 1e9;
|
|
249
|
+
const ok = gb >= 1;
|
|
250
|
+
return {
|
|
251
|
+
id: "disk",
|
|
252
|
+
label: "Disk space",
|
|
253
|
+
ok,
|
|
254
|
+
required: false,
|
|
255
|
+
detail: `${gb.toFixed(1)} GB free where proxies are stored.`,
|
|
256
|
+
fix: ok ? undefined : "Free up disk space before rendering more proxies.",
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Every doctor check, in order: Node, ffmpeg, ffprobe, which agent harnesses have Rushes
|
|
261
|
+
* registered, then this project's own state (files, server, disk). Outside a project folder
|
|
262
|
+
* (Review Focus 5), the project checks collapse into one line saying so, read: true, required:
|
|
263
|
+
* false -- the environment checks above it still run in full.
|
|
264
|
+
*/
|
|
265
|
+
export async function runDoctor(env) {
|
|
266
|
+
const checks = [nodeCheck(env), await ffmpegCheck(env), await ffprobeCheck(env)];
|
|
267
|
+
const all = harnesses(env.home, env.platform, env.appData);
|
|
268
|
+
const present = [];
|
|
269
|
+
for (const h of all)
|
|
270
|
+
if (await installed(h, env))
|
|
271
|
+
present.push(h);
|
|
272
|
+
if (!present.length) {
|
|
273
|
+
checks.push({ id: "agents", label: "Agent harnesses", ok: true, required: false, detail: "No supported agent harness found on this machine." });
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
const harnessChecks = [];
|
|
277
|
+
for (const h of present)
|
|
278
|
+
harnessChecks.push(await harnessCheck(h, env));
|
|
279
|
+
checks.push(...harnessChecks.map(({ unknown: _unknown, ...c }) => c));
|
|
280
|
+
// Controller ruling: when every installed harness is unregistered, say so once in plain words
|
|
281
|
+
// rather than making the reader infer it from a run of individual crosses. A harness that
|
|
282
|
+
// couldn't be checked isn't known to be unregistered, so it doesn't count.
|
|
283
|
+
if (harnessChecks.every((c) => !c.ok && !c.unknown)) {
|
|
284
|
+
checks.push({ id: "agents", label: "Agent harnesses", ok: false, required: false, detail: "No agent has Rushes yet.", fix: "Run rushes setup" });
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (!(await exists(join(env.cwd, RUSHES_DIR)))) {
|
|
288
|
+
checks.push({ id: "project", label: "Rushes project", ok: true, required: false, detail: "No Rushes project in this folder." });
|
|
289
|
+
return checks;
|
|
290
|
+
}
|
|
291
|
+
const store = new Store(env.cwd);
|
|
292
|
+
for (const key of Object.keys(FILES)) {
|
|
293
|
+
const name = FILES[key].name;
|
|
294
|
+
try {
|
|
295
|
+
await store.read(key);
|
|
296
|
+
checks.push({ id: `file:${key}`, label: name, ok: true, required: true, detail: "valid." });
|
|
297
|
+
}
|
|
298
|
+
catch (e) {
|
|
299
|
+
checks.push({ id: `file:${key}`, label: name, ok: false, required: true, detail: e.message, fix: `Fix or restore ${name}, or delete the ${RUSHES_DIR} folder and run rushes init to start over.` });
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
checks.push(await serverCheck(env.cwd));
|
|
303
|
+
const disk = await diskSpaceCheck(env);
|
|
304
|
+
if (disk)
|
|
305
|
+
checks.push(disk);
|
|
306
|
+
return checks;
|
|
307
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { longRunningCommand, main } from "./main.js";
|
|
3
|
+
const argv = process.argv.slice(2);
|
|
4
|
+
const code = await main(argv, {
|
|
5
|
+
out: (l) => console.log(l),
|
|
6
|
+
err: (l) => console.error(l),
|
|
7
|
+
cwd: process.cwd(),
|
|
8
|
+
});
|
|
9
|
+
// open, serve and mcp keep running on their own handles; everything else exits.
|
|
10
|
+
if (!longRunningCommand(argv) || code !== 0)
|
|
11
|
+
process.exit(code);
|