HyperFrames CLI
一切透過 npx hyperframes 執行。需要 Node.js >= 22 與 FFmpeg。
工作流程
- 脚手架 —
npx hyperframes init my-video - 編寫 — 撰寫 HTML 編排(請見
hyperframes技能) - 檢查 —
npx hyperframes lint - 視覺檢查 —
npx hyperframes inspect - 預覽 —
npx hyperframes preview - 渲染 —
npx hyperframes render
在預覽前先執行 lint 與 inspect。lint 會偵測缺少 data-composition-id、重疊的軌道與未註冊的時間軸。inspect 在無頭 Chrome 中開啟渲染後的編排,掃描時間軸,並回報文字溢出氣泡/容器或畫布外的情況。
脚手架
npx hyperframes init my-video # 互動式精靈
npx hyperframes init my-video --example warm-grain # 選取範例
npx hyperframes init my-video --video clip.mp4 # 搭配影片檔案
npx hyperframes init my-video --audio track.mp3 # 搭配音訊檔案
npx hyperframes init my-video --example blank --tailwind # 搭配 Tailwind v4 瀏覽器執行環境
npx hyperframes init my-video --non-interactive # 略過提示(CI/代理)
範本:blank, warm-grain, play-mode, swiss-grid, vignelli, decision-tree, kinetic-type, product-promo, nyt-graph。
init 會建立正確的檔案結構、複製媒體、使用 Whisper 轉錄音訊,並安裝 AI 編碼技能。請使用此命令,而非手動建立檔案。
使用 --tailwind 時,在編輯類別或主題令牌前,請先呼叫 tailwind 技能。此脚手架使用 Tailwind v4.2 瀏覽器執行環境,而非 Studio 的 Tailwind v3 設定。
程式碼檢查
npx hyperframes lint # 當前目錄
npx hyperframes lint ./my-project # 指定專案
npx hyperframes lint --verbose # 資訊層級的發現
npx hyperframes lint --json # 機器可讀
會檢查 index.html 與 compositions/ 目錄內的所有檔案。回報錯誤(必須修正)、警告(應修正)與資訊(搭配 --verbose)。
視覺檢查
npx hyperframes inspect # 檢查時間軸上的渲染佈局
npx hyperframes inspect ./my-project # 指定專案
npx hyperframes inspect --json # 代理可讀的發現
npx hyperframes inspect --samples 15 # 更密集的時間軸掃描
npx hyperframes inspect --at 1.5,4,7.25 # 明確的主力畫格時間點
請在 lint 與 validate 之後使用此命令,特別是對於包含對話氣泡、卡片、字幕或緊密排版的編排。它會回報:
- 文字超出最近的可視容器或氣泡
- 文字被自身的固定寬度/固定高度框裁剪
- 文字超出編排畫布
- 子元素逃脫裁剪容器
錯誤應在渲染前修正。警告會呈現給代理審查;加上 --strict 則會在出現警告時也失敗。重複的靜態問題會預設被折疊,以便 JSON 輸出保持精簡,適合 LLM 上下文視窗。如果溢出是刻意設計的進入/離開動畫,請在元素或祖先加上 data-layout-allow-overflow。如果裝飾性元素不應被審計,請加上 data-layout-ignore。
npx hyperframes layout 仍保留作為相同視覺檢查的相容別名。
預覽
npx hyperframes preview # 提供當前目錄的服務
npx hyperframes preview --port 4567 # 自訂埠號(預設 3002)
檔案變更時會熱重載。自動在瀏覽器中開啟 Studio。
當將專案交回給使用者時,請使用 Studio 專案 URL,而非原始的 index.html 路徑:
http://localhost:<port>/#project/<project-name>
請使用預覽輸出中的實際埠號與專案目錄名稱。例如,在 codex-openai-video 中執行 npx hyperframes preview --port 3017 後,回報 http://localhost:3017/#project/codex-openai-video。
請將 index.html 視為原始碼上下文。可以將其連結為實作檔案,但不要將其標記為專案或預覽表面。
渲染
npx hyperframes render # 標準 MP4
npx hyperframes render --output final.mp4 # 命名輸出
npx hyperframes render --quality draft # 快速迭代
npx hyperframes render --fps 60 --quality high # 最終交付
npx hyperframes render --format webm # 透明 WebM
npx hyperframes render --docker # 位元組一致
| 旗標 | 選項 | 預設 | 備註 |
|---|---|---|---|
--output | 路徑 | renders/名稱_時間戳.mp4 | 輸出路徑 |
--fps | 24, 30, 60 | 30 | 60fps 渲染時間加倍 |
--quality | draft, standard, high | standard | draft 用於迭代 |
--format | mp4, webm | mp4 | WebM 支援透明度 |
--workers | 1-8 或 auto | auto | 每個啟動一個 Chrome |
--docker | 旗標 | 關閉 | 可重現的輸出 |
--gpu | 旗標 | 關閉 | GPU 加速編碼 |
--strict | 旗標 | 關閉 | 在 lint 錯誤時失敗 |
--strict-all | 旗標 | 關閉 | 在錯誤與警告時都失敗 |
--variables | JSON 物件 | — | 覆蓋 data-composition-variables 中宣告的變數值 |
--variables-file | 路徑 | — | 包含變數值的 JSON 檔案(替代 --variables) |
--strict-variables | 旗標 | 關閉 | 在 --variables 中有未宣告的鍵或型別不符時渲染失敗 |
品質建議: 迭代時使用 draft,審查時使用 standard,最終交付時使用 high。
參數化渲染: 編排在 <html> 根元素上使用 data-composition-variables 宣告其變數 — 這是一個 JSON 宣告陣列(每個條目包含 {id, type, label, default}),定義了綱要。內部的腳本透過 window.__hyperframes.getVariables() 讀取解析後的值。CLI 的 --variables '{"title":"Q4 Report"}' 是一個以 id 為鍵的 JSON 物件,會覆蓋已宣告的預設值以進行一次渲染;缺少的鍵會回退,因此同一編排在開發預覽與生產環境中可以不加修改地執行。(子編排宿主也可以使用 data-variable-values 來覆蓋每個實例的值 — 物件形狀相同,作用範圍僅限於子編排的一次掛載。完整模式請見 hyperframes 技能。)
資源預處理
npx hyperframes tts、transcribe 與 remove-background 會產出可供編排使用的資源(旁白音訊、逐字稿、透明影片)。每個命令在首次執行時會下載各自的模型。對於語音選擇、Whisper 模型規則(.en 會翻譯非英文的陷阱)、輸出格式選擇(VP9 透明 WebM 與 ProRes),以及 TTS → 轉錄 → 字幕鏈,請呼叫 hyperframes-media 技能。
除錯
npx hyperframes doctor # 檢查環境(Chrome、FFmpeg、Node、記憶體)
npx hyperframes browser # 管理內建 Chrome
npx hyperframes info # 版本與環境詳細資訊
npx hyperframes upgrade # 檢查更新
如果渲染失敗,請先執行 doctor。常見問題:缺少 FFmpeg、缺少 Chrome、記憶體不足。
其他
npx hyperframes compositions # 列出專案中的編排
npx hyperframes docs # 開啟文件
npx hyperframes benchmark . # 基準測試渲染效能