From 48744a0eb662d86c62e0bc5c599ad67606c44ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Zander?= <96420681+renezander030@users.noreply.github.com> Date: Mon, 23 Nov 2026 10:43:11 +0000 Subject: [PATCH 1/4] Return dub's placed clips with the caller's own fields planDubClips takes the caller's clip type and returns it with durationUs and trimmed added, so cmdDub reads each clip's path and text directly instead of matching a placed clip back by cue and start time. No output change; a test pins the returned order and fields. Co-Authored-By: Claude Opus 5.5 --- src/dub.ts | 19 +++++++++++-------- src/index.ts | 7 +++---- test/dub.test.mjs | 17 +++++++++++++++++ 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/dub.ts b/src/dub.ts index cbcbbfc..14f24ec 100644 --- a/src/dub.ts +++ b/src/dub.ts @@ -22,14 +22,16 @@ export function cueSpeechText(text: string): string { .join(" "); } -export interface DubClip { +/** A clip to place: its cue, where it starts and how long its speech runs. Callers may carry more fields along. */ +export interface DubSpeech { cue: number; startUs: number; speechUs: number; - durationUs: number; - trimmed: boolean; } +/** A placed clip: the caller's clip with every field it carried, plus its length on the track. */ +export type DubClip = T & { durationUs: number; trimmed: boolean }; + export interface Occupied { startUs: number; endUs: number; @@ -37,15 +39,16 @@ export interface Occupied { /** * Place each clip at its cue's start for its full speech length. A clip that would run into the next clip or into a - * segment already on the track is refused, or cut at that point with `trimOverlap`. Returns the clips or the refusals. + * segment already on the track is refused, or cut at that point with `trimOverlap`. Returns the clips (in start + * order, each still carrying the caller's own fields) or the refusals. */ -export function planDubClips( - clips: Array<{ cue: number; startUs: number; speechUs: number }>, +export function planDubClips( + clips: T[], occupied: Occupied[], trimOverlap: boolean, -): { clips: DubClip[]; refusals: string[] } { +): { clips: DubClip[]; refusals: string[] } { const ordered = [...clips].sort((a, b) => a.startUs - b.startUs); - const out: DubClip[] = []; + const out: DubClip[] = []; const refusals: string[] = []; for (let i = 0; i < ordered.length; i++) { const clip = ordered[i]; diff --git a/src/index.ts b/src/index.ts index 7ca5155..4d50178 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2974,9 +2974,8 @@ async function cmdDub(draft: Draft, filePath: string, positional: string[], flag let clips: Array>; try { clips = plan.clips.map((clip) => { - const source = spoken.find((s) => s.cue === clip.cue && s.startUs === clip.startUs) as (typeof spoken)[number]; const result = addAudio(draft, filePath, { - path: source.path, + path: clip.path, start: clip.startUs, duration: clip.durationUs, volume: flags.volume, @@ -2985,12 +2984,12 @@ async function cmdDub(draft: Draft, filePath: string, positional: string[], flag return { cue: clip.cue, segment_id: result.segmentId, - path: source.path, + path: clip.path, start_us: clip.startUs, duration_us: clip.durationUs, speech_us: clip.speechUs, trimmed: clip.trimmed, - text: source.text, + text: clip.text, }; }); saveDraft(filePath, draft); diff --git a/test/dub.test.mjs b/test/dub.test.mjs index 0b652a5..f10e047 100644 --- a/test/dub.test.mjs +++ b/test/dub.test.mjs @@ -118,6 +118,23 @@ describe("dub — cue reading and placement", () => { ); assert.deepEqual(r.refusals, ["cue 4: its speech runs 0.500 s into a segment already on the track"]); }); + it("returns each placed clip in start order with the fields the caller gave it", () => { + const r = planDubClips( + [ + { cue: 2, startUs: 5_000_000, speechUs: 1_000_000, path: "b.wav" }, + { cue: 1, startUs: 0, speechUs: 1_000_000, path: "a.wav" }, + ], + [], + false, + ); + assert.deepEqual( + r.clips.map((c) => [c.cue, c.path, c.durationUs]), + [ + [1, "a.wav", 1_000_000], + [2, "b.wav", 1_000_000], + ], + ); + }); }); describe("dub — the command", { skip: isWindows && "fake TTS and ffprobe are #! scripts" }, () => { From 26e3ae31723749e59129d66a9cf761336bdba5cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Zander?= <96420681+renezander030@users.noreply.github.com> Date: Mon, 23 Nov 2026 10:43:11 +0000 Subject: [PATCH 2/4] Read the runtime's path from the portable layout, and wait for Windows to release a relocated folder The per-target layout now names where the runtime sits in a Node distribution, so buildPortable no longer branches on windows for it. The relocation test renames through renameWhenReleased, which retries a momentary EPERM/EBUSY/EACCES on Windows only (the v0.37.0 release run's windows-2025 job hit one; the same test passed in CI on that commit). Co-Authored-By: Claude Opus 5.5 --- scripts/build-portable.mjs | 10 ++++++---- test/portable.test.mjs | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/scripts/build-portable.mjs b/scripts/build-portable.mjs index c7dcd2e..987062c 100644 --- a/scripts/build-portable.mjs +++ b/scripts/build-portable.mjs @@ -108,10 +108,11 @@ const SH_LAUNCHER = [ "", ].join("\n"); -/** What differs per target once the runtime is checked: its file name, the launchers and the archive format. */ +/** What differs per target: where the runtime sits in a Node distribution, its name, the launchers and the archive. */ function portableLayout(windows, tar) { if (windows) { return { + runtimeSource: ["node.exe"], runtimeName: "node.exe", extension: "zip", writeLaunchers: (payload) => { @@ -121,6 +122,7 @@ function portableLayout(windows, tar) { }; } return { + runtimeSource: ["bin", "node"], runtimeName: "node", extension: "tar.gz", writeLaunchers: (payload) => { @@ -146,10 +148,11 @@ export function buildPortable({ outDir, nodeRoot, root = sourceRoot, target = po // Windows' own tar (bsdtar); Git's GNU tar earlier on a runner's PATH reads "C:\\..." as a remote host const tar = process.platform === "darwin" ? "gtar" : process.platform === "win32" ? join(process.env.SystemRoot || "C:\\Windows", "System32", "tar.exe") : "tar"; if (!windows && !run(tar, ["--version"]).includes("GNU tar")) throw new Error("Building portable archives requires GNU tar (gnu-tar on macOS)"); - const node = windows ? join(nodeRoot, "node.exe") : join(nodeRoot, "bin", "node"); + const layout = portableLayout(windows, tar); + const node = join(nodeRoot, ...layout.runtimeSource); const license = join(nodeRoot, "LICENSE"); if (!existsSync(node) || !existsSync(license)) { - throw new Error(windows ? "Use a complete official Node distribution with node.exe and LICENSE" : "Use a complete official Node distribution with bin/node and LICENSE"); + throw new Error(`Use a complete official Node distribution with ${layout.runtimeSource.join("/")} and LICENSE`); } let runtime; if (target === host) { @@ -175,7 +178,6 @@ export function buildPortable({ outDir, nodeRoot, root = sourceRoot, target = po const name = `capcut-cli-v${version}-${target}`; const output = resolve(outDir); mkdirSync(output, { recursive: true }); - const layout = portableLayout(windows, tar); const archive = join(output, `${name}.${layout.extension}`); const checksum = `${archive}.sha256`; if (existsSync(archive) || existsSync(checksum)) throw new Error("Portable output already exists; choose an empty output directory"); diff --git a/test/portable.test.mjs b/test/portable.test.mjs index a10cb6c..2fe897d 100644 --- a/test/portable.test.mjs +++ b/test/portable.test.mjs @@ -17,6 +17,20 @@ import { dirname, join, relative, resolve } from "node:path"; import { after, before, describe, it } from "node:test"; import { buildPortable, PORTABLE_TARGETS, portableTarget } from "../scripts/build-portable.mjs"; +// Windows keeps a handle on a folder for a moment after a process run from it exits (seen on the windows-2025 release +// runner, 23 Nov: EPERM on this rename while the same test passed twice in CI); retry that briefly, nothing else. +function renameWhenReleased(from, to) { + for (let tries = 0; ; tries++) { + try { + return renameSync(from, to); + } catch (error) { + if (process.platform !== "win32" || !["EPERM", "EBUSY", "EACCES"].includes(error.code) || tries >= 20) + throw error; + Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 100); + } + } +} + const windows = process.platform === "win32"; const runtimeRoot = process.env.CAPCUT_PORTABLE_NODE_ROOT || @@ -93,7 +107,7 @@ describe("portable distribution", { }); it("remains relocatable when the directory contains spaces", () => { const moved = join(root, "relocated package"); - renameSync(extracted, moved); + renameWhenReleased(extracted, moved); extracted = moved; assert.equal(invoke("capcut", ["--version"]).trim(), receipt.version); }); From 81c0b9c8e71c1f448ead10cc90e084daa70a2a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Zander?= <96420681+renezander030@users.noreply.github.com> Date: Mon, 23 Nov 2026 10:43:12 +0000 Subject: [PATCH 3/4] Read the version registry's broken and ceiling rules in one place registryVerdict gives the write guard and capcut version the same known-broken and beyond-ceiling answers, which each computed on its own. Output is byte-identical. Co-Authored-By: Claude Opus 5.5 --- src/version.ts | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/version.ts b/src/version.ts index 018a5b1..f59798e 100644 --- a/src/version.ts +++ b/src/version.ts @@ -89,6 +89,23 @@ const SUPPORTED_APP_VERSIONS: Record = { }, }; +/** + * Where a version sits against its app's registry entry: the first + * known-broken boundary it reaches (any version >= `min`), and whether it is + * newer than the evidence ceiling. The one place these two registry rules are + * read, so the write guard and the `capcut version` assessment cannot drift. + */ +function registryVerdict( + registry: VersionRegistryEntry, + version: string | null, +): { broken: VersionRegistryEntry["broken"][number] | undefined; beyondCeiling: boolean } { + if (version === null) return { broken: undefined, beyondCeiling: false }; + return { + broken: registry.broken.find((entry) => atLeast(version, entry.min)), + beyondCeiling: registry.ceiling !== null && !atLeast(registry.ceiling, version), + }; +} + // Highest top-level `version` schema integer observed in any real draft corpus // (constant across all known CapCut 8.x fixtures). Evidence level: reported — // the observing fixtures are not committed in this repo. A larger value means @@ -199,11 +216,10 @@ export function assessWriteSafety(draft: Draft, storeVersion: string | null): Wr const app_version = candidates.sort((a, b) => (atLeast(a, b) ? -1 : 1))[0] ?? null; const registry = SUPPORTED_APP_VERSIONS[app_source]; - const beyondCeiling = app_version !== null && registry.ceiling !== null && !atLeast(registry.ceiling, app_version); + const { broken: brokenMatch, beyondCeiling } = registryVerdict(registry, app_version); const beyond_known_range = beyondCeiling || (schema_int !== null && schema_int > KNOWN_SCHEMA_INT_MAX); const detected = { app_source, app_version, schema_int, beyond_known_range }; - const brokenMatch = app_version !== null ? registry.broken.find((entry) => atLeast(app_version, entry.min)) : null; if (brokenMatch) { return { action: "refuse", @@ -370,7 +386,8 @@ function assessSupport( notes: [...notes, "No `platform.app_version` field — cannot assess compatibility"], }; } - const brokenMatch = matrix.broken.find((entry) => atLeast(app_version, entry.min)); + const verdict = registryVerdict(matrix, app_version); + const brokenMatch = verdict.broken; if (brokenMatch) { notes.push(`Version ${app_version} listed as known-broken (>= ${brokenMatch.min}: ${brokenMatch.reason})`); return { status: "known-broken", evidence: "reported", notes }; @@ -396,7 +413,7 @@ function assessSupport( ); return { status: "untested", evidence: "expected-compatible", notes }; } - if (matrix.ceiling !== null && !atLeast(matrix.ceiling, app_version)) { + if (verdict.beyondCeiling) { notes.push( `Version ${app_version} is beyond the known range (${matrix.range}) — no evidence this CLI can round-trip it`, ); From e479d6dc6352a29439660edc9159713392d95b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Zander?= <96420681+renezander030@users.noreply.github.com> Date: Mon, 23 Nov 2026 10:43:12 +0000 Subject: [PATCH 4/4] Generate the Chinese command reference from describe, and release 0.37.1 docs/command-reference.zh-CN.md had 85 of 89 commands (no dub, matting, catalogue or detect-retakes) and 11 stale usages. The generator now writes its table from describe and keeps each translated summary, and the drift test covers it. Version 0.37.1 with its changelog. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 6 ++++ README.md | 28 +++++++++---------- docs/command-reference.json | 2 +- docs/command-reference.zh-CN.md | 24 +++++++++------- package-lock.json | 4 +-- package.json | 2 +- scripts/generate-command-docs.mjs | 46 ++++++++++++++++++++++++++----- test/command-reference.test.mjs | 44 ++++++++++++++++++++++++++--- 8 files changed, 117 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98b5cbd..abd7fed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to capcut-cli are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); the project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.37.1] - 2026-11-23 + +### Fixed +- The Chinese command reference (`docs/command-reference.zh-CN.md`) lists every command `capcut describe` knows, `dub`, `matting`, `catalogue` and `detect-retakes` among them, with current usages; it is generated with the English reference and checked against `describe` like it. +- The Windows relocation check of the portable archive waits for Windows to release the folder after the bundled runtime exits, instead of failing on a momentary lock. + ## [0.37.0] - 2026-11-22 ### Added diff --git a/README.md b/README.md index 177f9e9..6a36332 100644 --- a/README.md +++ b/README.md @@ -34,16 +34,16 @@ npm install -g capcut-cli ### Portable downloads without installing Node or npm -Download `capcut-cli-v0.37.0-linux-x64.tar.gz` and its `.sha256` file from the [release assets](https://github.com/renezander030/capcut-cli/releases). Verify and extract them together: +Download `capcut-cli-v0.37.1-linux-x64.tar.gz` and its `.sha256` file from the [release assets](https://github.com/renezander030/capcut-cli/releases). Verify and extract them together: ```sh -sha256sum -c capcut-cli-v0.37.0-linux-x64.tar.gz.sha256 -tar -xzf capcut-cli-v0.37.0-linux-x64.tar.gz -./capcut-cli-v0.37.0-linux-x64/capcut --version -./capcut-cli-v0.37.0-linux-x64/capcut describe --compact +sha256sum -c capcut-cli-v0.37.1-linux-x64.tar.gz.sha256 +tar -xzf capcut-cli-v0.37.1-linux-x64.tar.gz +./capcut-cli-v0.37.1-linux-x64/capcut --version +./capcut-cli-v0.37.1-linux-x64/capcut describe --compact ``` -On Linux arm64 (aarch64), choose `capcut-cli-v0.37.0-linux-arm64.tar.gz` and its matching `.sha256` file, then use the same verification and extraction commands with that filename. Use the archive matching the machine architecture; these archives bundle Node, not ffmpeg or the desktop editor. +On Linux arm64 (aarch64), choose `capcut-cli-v0.37.1-linux-arm64.tar.gz` and its matching `.sha256` file, then use the same verification and extraction commands with that filename. Use the archive matching the machine architecture; these archives bundle Node, not ffmpeg or the desktop editor. Keep the whole extracted directory together; it includes the Node runtime and its license. Both `capcut` and `capcut-cli` launchers work after moving the directory. Linux archives target x64 or arm64 with glibc (not Alpine/musl); optional FFmpeg/Whisper tools remain separate. This is a portable directory, not a single-file executable. @@ -52,18 +52,18 @@ You can add the extracted directory to `PATH` or create symbolic links to `capcu On macOS, choose `darwin-arm64` for Apple Silicon or `darwin-x64` for Intel. Download the matching archive and checksum from the same release, then verify and extract them (Apple Silicon example): ```sh -shasum -a 256 -c capcut-cli-v0.37.0-darwin-arm64.tar.gz.sha256 -tar -xzf capcut-cli-v0.37.0-darwin-arm64.tar.gz -./capcut-cli-v0.37.0-darwin-arm64/capcut --version +shasum -a 256 -c capcut-cli-v0.37.1-darwin-arm64.tar.gz.sha256 +tar -xzf capcut-cli-v0.37.1-darwin-arm64.tar.gz +./capcut-cli-v0.37.1-darwin-arm64/capcut --version ``` -On Windows x64 (from release 0.37.0 on), download `capcut-cli-v0.37.0-win-x64.zip` and its `.sha256` file. In PowerShell, compare the hash with the one in the `.sha256` file, extract, and run the `capcut.cmd` launcher: +On Windows x64 (from release 0.37.1 on), download `capcut-cli-v0.37.1-win-x64.zip` and its `.sha256` file. In PowerShell, compare the hash with the one in the `.sha256` file, extract, and run the `capcut.cmd` launcher: ```powershell -(Get-FileHash capcut-cli-v0.37.0-win-x64.zip -Algorithm SHA256).Hash.ToLower() -Get-Content capcut-cli-v0.37.0-win-x64.zip.sha256 -Expand-Archive capcut-cli-v0.37.0-win-x64.zip -DestinationPath . -.\capcut-cli-v0.37.0-win-x64\capcut.cmd --version +(Get-FileHash capcut-cli-v0.37.1-win-x64.zip -Algorithm SHA256).Hash.ToLower() +Get-Content capcut-cli-v0.37.1-win-x64.zip.sha256 +Expand-Archive capcut-cli-v0.37.1-win-x64.zip -DestinationPath . +.\capcut-cli-v0.37.1-win-x64\capcut.cmd --version ``` The folder holds the official Node runtime (`runtime\node.exe` and its license); `capcut.cmd` and `capcut-cli.cmd` work from any location, also with spaces in the path, and you can add the folder to `PATH`. Arguments pass through `cmd.exe`, so quote values containing `&`, `|`, `<`, `>` or `^`. Every release builds this archive on a Windows runner and runs it there before publishing. diff --git a/docs/command-reference.json b/docs/command-reference.json index 062726c..269a2c4 100644 --- a/docs/command-reference.json +++ b/docs/command-reference.json @@ -1,6 +1,6 @@ { "name": "capcut-cli", - "version": "0.37.0", + "version": "0.37.1", "schema_version": 2, "description": "Edit CapCut/JianYing draft_content.json directly. JSON in, JSON out.", "global_flags": [ diff --git a/docs/command-reference.zh-CN.md b/docs/command-reference.zh-CN.md index 6f0c3d7..0665359 100644 --- a/docs/command-reference.zh-CN.md +++ b/docs/command-reference.zh-CN.md @@ -23,7 +23,7 @@ | `opacity` | `capcut opacity ` | 是 | 设置片段不透明度(0.0-1.0)。 | | `export-srt` | `capcut export-srt [options]` | 否 | 把字幕导出为 SRT 或 WebVTT(输出到 stdout),按行或按词。 | | `export-ass` | `capcut export-ass [--karaoke] [--out ]` | 否 | 把带样式的 ASS 字幕导出到 stdout 或 --out,支持按区间的样式覆盖;--karaoke 输出逐词时间。 | -| `export-timeline` | `capcut export-timeline [--out ]` | 否 | 把视频/音频轨道导出为 OpenTimelineIO JSON,交接给 NLE(DaVinci Resolve 原生导入 .otio)。 | +| `export-timeline` | `capcut export-timeline [--out ] [--captions skip\|markers]` | 否 | 把视频/音频轨道导出为 OpenTimelineIO JSON,交接给 NLE(DaVinci Resolve 原生导入 .otio)。 | | `import-timeline` | `capcut import-timeline (--out \| --into )` | 是 | 导入 OpenTimelineIO JSON,把嵌套的 Timeline/Stack/Track 展平,生成新草稿(--out)或追加到已有草稿(--into);不支持的 OTIO 特性一律报告,绝不静默丢弃。 | | `materials` | `capcut materials [--type ]` | 否 | 列出素材类型与数量;用 --type 过滤。 | | `segment` | `capcut segment ` | 否 | 单个片段及其素材的完整详情。 | @@ -31,7 +31,8 @@ | `add-audio` | `capcut add-audio [duration] [options]` | 是 | 在音频轨道上添加本地或 Wikimedia 音频文件。 | | `add-video` | `capcut add-video [duration] [options]` | 是 | 在视频轨道上添加本地或 Wikimedia 视频/图片。 | | `add-text` | `capcut add-text [options]` | 是 | 添加文本片段,带字体/颜色/位置选项。 | -| `tts` | `capcut tts [start] [duration] (--text \| --text-file ) --tts-cmd