fix(cli): fixed-name outputs and history turn records replace a link, never write through it (#7911)

* fix(cli): fixed-name outputs and history turn records replace a link, never write through it

transcript.json, hyperframes.json patches, the grade-compare sheet, the batch manifest, diff and
measure outputs, lambda stack state and the history turn records are written through a temp file
renamed into place. A linked hyperframes.json is left alone, and the default .hyperframes/<tool>
output folder is used only when every folder on the way is real.

* fix(cli): measure and diff pictures and sbs.mp4 replace a link, never write through it

writeImage and the diff side-by-side now have ffmpeg write into a new private folder beside the
output, then rename the file over its name. measure frames already staged and renamed its PNGs.
This commit is contained in:
Michael Wang
2026-11-16 02:59:43 +00:00
committed by GitHub
parent 5892788cb3
commit 756b2fcae1
13 changed files with 261 additions and 57 deletions
+3 -2
View File
@@ -1,4 +1,5 @@
import { existsSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
import { replaceFileAtomically } from "@hyperframes/core/atomic-file";
import { basename, dirname, extname, join, resolve } from "node:path";
import { transcribeWithHeygen } from "../heygen/transcribe.js";
import { normalizeErrorMessage } from "../utils/errorMessage.js";
@@ -279,7 +280,7 @@ function importTranscript(inputPath: string, dir: string): TranscribeResult {
const { words, format } = readTranscript(inputPath);
const transcriptPath = join(dir, TRANSCRIPT_FILE);
writeFileSync(transcriptPath, JSON.stringify(words, null, 2));
replaceFileAtomically(transcriptPath, JSON.stringify(words, null, 2));
patchCaptionHtml(dir, words);
return { kind: "imported", format, wordCount: words.length, transcriptPath };
}
@@ -387,7 +388,7 @@ function finishTranscript(
): TranscribeResult {
const { words } = loadTranscript(result.transcriptPath);
writeFileSync(result.transcriptPath, JSON.stringify(words, null, 2));
replaceFileAtomically(result.transcriptPath, JSON.stringify(words, null, 2));
patchCaptionHtml(dir, words);
if (sidecar) {
try {