import { defineCommand } from "citty"; import { existsSync, readFileSync, mkdirSync, writeFileSync } from "node:fs"; import { resolve, join, dirname } from "node:path"; import { findMusicAudioSrc, audioRelPathForSrc, serializeBeats } from "@hyperframes/core/beats"; import type { Example } from "./_examples.js"; import { resolveProject, type ProjectDir } from "../utils/project.js"; import { analyzeBeatsHeadless, type HeadlessBeatResult } from "../beats/headlessAnalyzer.js"; import { c } from "../ui/colors.js"; export const examples: Example[] = [ ["Generate the beat file for the current project", "hyperframes beats"], ["Generate for a specific directory", "hyperframes beats ./my-video"], ]; function fail(message: string): never { console.error(c.error(message)); process.exit(1); } /** Locate the music track + its on-disk audio, or fail with a clear message. */ function resolveMusicTarget(project: ProjectDir): { rel: string; audioPath: string } { const src = findMusicAudioSrc(readFileSync(project.indexPath, "utf-8")); if (!src) { fail( 'No music track found. Add data-timeline-role="music" to the