Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/packages/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,11 @@ plugin) with its path, Node.js, CPU, memory, disk, the extracted-frame cache,
the archive extractor, `/dev/shm` on Linux, environment, whisper-cpp, local TTS
and BGM models, FFmpeg, FFprobe, Chrome, and Docker.

whisper-cpp and the local TTS and BGM models are optional. When one is missing
its row shows `○` with the install command, and it does not fail the run: the
summary reads `All required checks passed`, and in `--json` the row carries
`"optional": true` and leaves the top-level `ok` true.

The **frames cache** row is worth knowing about: it prints the effective cache
directory, its free space, and whether the location came from
`HYPERFRAMES_EXTRACT_CACHE_DIR` or the default. Under 2 GB free it fails, since
Expand Down
36 changes: 36 additions & 0 deletions packages/cli/src/commands/doctor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { optionalPackageDir } from "../utils/optionalPackages.js";
import {
TESTED_FFMPEG_VERSION,
buildDoctorReport,
doctorSummary,
ffmpegDoctorDetail,
checkDocker,
checkDockerRunning,
Expand Down Expand Up @@ -45,6 +46,28 @@ const OUTCOMES_WITH_FAILURE: CheckOutcome[] = [
},
];

const OPTIONAL_MISSING: CheckOutcome[] = [
{ name: "TTS (Kokoro)", ok: false, detail: "Not installed (optional)", optional: true },
{ name: "BGM (MusicGen)", ok: false, detail: "Not installed (optional)", optional: true },
];

describe("doctorSummary", () => {
it("passes when only optional checks are missing, and names them", () => {
expect(doctorSummary([...OUTCOMES_ALL_OK, ...OPTIONAL_MISSING])).toEqual({
ok: true,
text: "All required checks passed \u2014 optional, not installed: TTS (Kokoro), BGM (MusicGen)",
});
});

it("fails when a required check fails", () => {
expect(doctorSummary([...OUTCOMES_WITH_FAILURE, ...OPTIONAL_MISSING]).ok).toBe(false);
});

it("says all checks passed when nothing is missing", () => {
expect(doctorSummary(OUTCOMES_ALL_OK)).toEqual({ ok: true, text: "All checks passed" });
});
});

describe("redactHome", () => {
const originalHome = process.env["HOME"];
const originalUserProfile = process.env["USERPROFILE"];
Expand Down Expand Up @@ -245,6 +268,19 @@ describe("buildDoctorReport", () => {
expect(buildDoctorReport(OUTCOMES_WITH_FAILURE).ok).toBe(false);
});

it("reports ok=true when only optional checks are missing, and marks them", () => {
const report = buildDoctorReport([...OUTCOMES_ALL_OK, ...OPTIONAL_MISSING], { redact: true });
expect(report.ok).toBe(true);
expect(report.checks.filter((c) => c.optional).map((c) => c.name)).toEqual([
"TTS (Kokoro)",
"BGM (MusicGen)",
]);
});

it("still reports ok=false when a required check fails beside optional ones", () => {
expect(buildDoctorReport([...OUTCOMES_WITH_FAILURE, ...OPTIONAL_MISSING]).ok).toBe(false);
});

it("preserves check order exactly as provided", () => {
const report = buildDoctorReport(OUTCOMES_ALL_OK);
expect(report.checks.map((c) => c.name)).toEqual(["Version", "Node.js", "FFmpeg"]);
Expand Down
67 changes: 46 additions & 21 deletions packages/cli/src/commands/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ interface CheckResult {
ok: boolean;
detail: string;
hint?: string;
optional?: boolean;
}

export { parseToolVersion };
Expand Down Expand Up @@ -317,6 +318,7 @@ async function checkWhisper(): Promise<CheckResult> {
ok: false,
detail: "Not found (optional \u2014 needed for transcription)",
hint: getInstallInstructions(),
optional: true,
};
}

Expand All @@ -331,6 +333,7 @@ function checkLocalVoice(): CheckResult {
ok: false,
detail: notInstalledDetail("Not installed (optional \u2014 local voice fallback)"),
hint: KOKORO_PIP,
optional: true,
};
}

Expand All @@ -340,6 +343,7 @@ function checkLocalMusic(): CheckResult {
ok: false,
detail: notInstalledDetail("Not installed (optional \u2014 local music fallback)"),
hint: MUSICGEN_PIP,
optional: true,
};
}

Expand All @@ -361,6 +365,34 @@ export interface CheckOutcome {
ok: boolean;
detail: string;
hint?: string;
optional?: boolean;
}

function toOutcome(name: string, result: CheckResult): CheckOutcome {
return {
name,
ok: result.ok,
detail: result.detail,
...(result.hint ? { hint: result.hint } : {}),
...(result.optional ? { optional: true } : {}),
};
}

function requiredChecksPass(outcomes: CheckOutcome[]): boolean {
return outcomes.every((o) => o.ok || o.optional);
}

/** The closing line of the human report; optional rows that are missing never turn it into a failure. */
export function doctorSummary(outcomes: CheckOutcome[]): { ok: boolean; text: string } {
if (!requiredChecksPass(outcomes)) {
return { ok: false, text: "Some checks failed \u2014 see hints above" };
}
const missing = outcomes.filter((o) => !o.ok).map((o) => o.name);
if (missing.length === 0) return { ok: true, text: "All checks passed" };
return {
ok: true,
text: `All required checks passed \u2014 optional, not installed: ${missing.join(", ")}`,
};
}

/**
Expand All @@ -380,6 +412,7 @@ function redactOutcome(o: CheckOutcome): CheckOutcome {
ok: o.ok,
detail: redactHome(o.detail),
...(o.hint ? { hint: redactHome(o.hint) } : {}),
...(o.optional ? { optional: true } : {}),
};
}

Expand All @@ -396,35 +429,39 @@ function redactOutcome(o: CheckOutcome): CheckOutcome {
export function buildDoctorReport(outcomes: CheckOutcome[], options: { redact?: boolean } = {}) {
const checks = options.redact ? outcomes.map(redactOutcome) : outcomes;
return withMeta({
ok: checks.every((o) => o.ok),
ok: requiredChecksPass(checks),
platform: process.platform,
arch: process.arch,
checks,
});
}

export function printDoctorOutcomes(outcomes: CheckOutcome[]): void {
const allOk = outcomes.every((o) => o.ok);
console.log();
console.log(c.bold("hyperframes doctor"));
console.log();

for (const outcome of outcomes) {
const icon = outcome.ok ? c.success("\u2713") : c.error("\u2717");
const icon = outcome.ok
? c.success("\u2713")
: outcome.optional
? c.warn("\u25CB")
: c.error("\u2717");
const name = terminalText(outcome.name).padEnd(16);
console.log(
` ${icon} ${c.bold(name)} ${outcome.ok ? c.dim(terminalLines(outcome.detail)) : c.error(terminalLines(outcome.detail))}`,
` ${icon} ${c.bold(name)} ${outcome.ok ? c.dim(terminalLines(outcome.detail)) : outcome.optional ? c.warn(terminalLines(outcome.detail)) : c.error(terminalLines(outcome.detail))}`,
);
if (!outcome.ok && outcome.hint) {
console.log(` ${" ".repeat(19)}${c.accent(terminalLines(outcome.hint))}`);
}
}

console.log();
if (allOk) {
console.log(` ${c.success("\u25C7")} ${c.success("All checks passed")}`);
const summary = doctorSummary(outcomes);
if (summary.ok) {
console.log(` ${c.success("\u25C7")} ${c.success(terminalText(summary.text))}`);
} else {
console.log(` ${c.warn("\u25C7")} ${c.warn("Some checks failed \u2014 see hints above")}`);
console.log(` ${c.warn("\u25C7")} ${c.warn(terminalText(summary.text))}`);
}
console.log();
}
Expand Down Expand Up @@ -463,13 +500,7 @@ export default defineCommand({

const outcomes: CheckOutcome[] = [];
for (const check of checks) {
const result = await check.run();
outcomes.push({
name: check.name,
ok: result.ok,
detail: result.detail,
...(result.hint ? { hint: result.hint } : {}),
});
outcomes.push(toOutcome(check.name, await check.run()));
}
for (const result of environment.outcomes) {
outcomes.push({
Expand All @@ -484,13 +515,7 @@ export default defineCommand({
{ name: "Docker", run: () => checkDocker() },
{ name: "Docker running", run: () => checkDockerRunning() },
]) {
const result = await check.run();
outcomes.push({
name: check.name,
ok: result.ok,
detail: result.detail,
...(result.hint ? { hint: result.hint } : {}),
});
outcomes.push(toOutcome(check.name, await check.run()));
}
if (args.json) {
// Exit code intentionally reflects command success, not environment
Expand Down
2 changes: 1 addition & 1 deletion skills-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"files": 85
},
"hyperframes-cli": {
"hash": "36ed7b39fe73ede2",
"hash": "df8a070d6cb64b3f",
"files": 14
},
"hyperframes-registry": {
Expand Down
1 change: 1 addition & 0 deletions skills/hyperframes-cli/references/doctor-browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Runs independent checks and reports each as ok/warn/fail:
- **Chrome** — bundled or system, version, path
- **Docker** / **Docker running** — required only for `render --docker`
- **/dev/shm** — inside containers only
- **whisper-cpp**, **TTS (Kokoro)**, **BGM (MusicGen)** — optional: a missing one shows `○`, carries `optional: true` in JSON and leaves `ok` true

Run `doctor` first when:

Expand Down
Loading