mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-23 11:29:54 +00:00
fix(cli): show control characters as text in capture, figma, usage and notice lines (#8366)
* fix(cli): keep notices and capture warnings to the line they are printed on A warning or failure reason from capture, and the command named in the left-out-files notice, could carry a line break and start a line of their own. They are printed as one line now, control characters shown as text. The figma component, usage and measure hands status lines go through the same helper. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * docs(cli): describe how printed lines show control characters and line breaks Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * docs(cli): name the commands whose printed lines changed Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
e8f52dc866
commit
7fcc4909b4
@@ -47,6 +47,14 @@ default to the current directory: `npx hyperframes check ./my-video`. A few
|
||||
take it as a flag instead — `add`, `transcribe`, `feedback`, `skills`, `history`, and
|
||||
the `timeline` edit commands use `--dir`.
|
||||
|
||||
**Control characters in a few printed lines.** `figma component` (the
|
||||
`imported component` line), `usage` (the reason on a `Usage unknown` line),
|
||||
`measure hands` (its notices) and `compare` and `keyframes` (the notice
|
||||
about files left out) print control characters in a repeated value as visible
|
||||
text such as `\x1b` and `\x07`, and keep the value on its line, with a line break
|
||||
shown as `\x0a`. [`capture`](#capture) does the same for its warnings and failure
|
||||
reason. `--json` output is not changed by this.
|
||||
|
||||
**`--json` for agents and scripts.** Most commands accept it, and the ones
|
||||
that do not reject it with exit 2. The payload is wrapped with a `_meta` field
|
||||
so a script can spot an outdated CLI from any command's output, without a
|
||||
@@ -410,6 +418,10 @@ the `/hyperframes` skill uses it when a real product has to appear on screen. Dy
|
||||
partial results, so read `dropped`, the warnings, and the contact sheets before
|
||||
you build.
|
||||
|
||||
Each warning, and the reason on a `Capture failed:` line, is printed on one
|
||||
line: a line break inside the text is shown as `\x0a` instead of starting a new
|
||||
terminal line. `--json` output is unchanged and carries the full text.
|
||||
|
||||
Downloaded fonts are saved under `assets/fonts/`, and their CSS references point
|
||||
to those local files. Distinct URLs such as `demo.woff2?v=1` and
|
||||
`demo.woff2?v=10` keep separate files. A failed font download leaves its original
|
||||
|
||||
@@ -491,7 +491,7 @@ describe("capture command: what it prints", () => {
|
||||
tokens: { sections: [], fonts: [] },
|
||||
assets: [],
|
||||
dropped: {},
|
||||
warnings: [] as string[],
|
||||
warnings: ["Kept the existing a\n ⚠ b.md"],
|
||||
} as never);
|
||||
|
||||
try {
|
||||
@@ -506,7 +506,26 @@ describe("capture command: what it prints", () => {
|
||||
expect(text).toContain("Capturing https://example.com/a\\x07b");
|
||||
// The folder is printed as a full path, whose root and separators differ by platform.
|
||||
expect(text).toMatch(/Captured Example → \S*hf-capture\\x1b\[2Jout/);
|
||||
expect(text).toContain("⚠ Kept the existing a\\x0a ⚠ b.md");
|
||||
expect(text).not.toContain("\u0007");
|
||||
expect(text).not.toContain("\u001b[2J");
|
||||
});
|
||||
|
||||
// fails without the fix: a line break in the reason started a line of its own
|
||||
it("keeps the reason a capture failed on one line", async () => {
|
||||
vi.useFakeTimers();
|
||||
registerRootExitRequester(() => {});
|
||||
const error = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
captureWebsiteMock.mockRejectedValueOnce(new Error("no route\n ✓ Captured"));
|
||||
const output = mkdtempSync(join(tmpdir(), "hf-capture-failed-"));
|
||||
try {
|
||||
await captureCommand.run!({ args: { url: "https://example.com", output } } as never);
|
||||
} catch {
|
||||
/* the run reports its failure by throwing too */
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
rmSync(output, { recursive: true, force: true });
|
||||
}
|
||||
expect(printed(error)).toContain("Capture failed: no route\\x0a ✓ Captured");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ import { diag } from "../ui/diagnostics.js";
|
||||
import type { CapturePhaseProgress } from "../capture/types.js";
|
||||
import { parseCaptureDeadline } from "../capture/captureWatchdog.js";
|
||||
import { jsonFailure, printFailureLine } from "../utils/jsonError.js";
|
||||
import { terminalLines, terminalText } from "@hyperframes/core";
|
||||
import { terminalText } from "@hyperframes/core";
|
||||
import { parseTimeoutMs } from "../utils/timeoutArg.js";
|
||||
|
||||
const CAPTURE_PHASE_PREFIX = "HYPERFRAMES_CAPTURE_PHASE ";
|
||||
@@ -335,7 +335,7 @@ export default defineCommand({
|
||||
if (result.warnings.length > 0) {
|
||||
console.log();
|
||||
for (const w of result.warnings) {
|
||||
console.log(` ${c.warn("⚠")} ${terminalLines(w)}`);
|
||||
console.log(` ${c.warn("⚠")} ${terminalText(w)}`);
|
||||
}
|
||||
}
|
||||
console.log();
|
||||
@@ -359,7 +359,7 @@ export default defineCommand({
|
||||
if (isJson) {
|
||||
console.log(JSON.stringify(jsonFailure("runtime_error", errMsg)));
|
||||
} else {
|
||||
console.error(`\n ✗ Capture failed: ${terminalLines(errMsg)}\n`);
|
||||
console.error(`\n ✗ Capture failed: ${terminalText(errMsg)}\n`);
|
||||
}
|
||||
scheduleCliExit(1);
|
||||
failCommand();
|
||||
|
||||
@@ -206,7 +206,9 @@ export default defineCommand({
|
||||
download: downloadRender,
|
||||
name: args.name,
|
||||
});
|
||||
console.log(`imported component "${result.name}" → ${result.htmlPath}`);
|
||||
console.log(
|
||||
`imported component "${terminalText(result.name)}" → ${terminalText(result.htmlPath)}`,
|
||||
);
|
||||
if (result.rasterized.length > 0) {
|
||||
const ok = result.rasterized.length - result.failedRasterize.length;
|
||||
console.log(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { terminalText } from "@hyperframes/core";
|
||||
import { defineCommand } from "../../utils/defineCommand.js";
|
||||
import type { Example } from "../_examples.js";
|
||||
import { jsonArg, num, runMeasure, videoArg, window } from "../../measure/command.js";
|
||||
@@ -67,7 +68,7 @@ export default defineCommand({
|
||||
which: choice(args.which, "--which", HAND_CHOICES, "largest"),
|
||||
fps: num(args.fps, "--fps", 15),
|
||||
},
|
||||
(message) => console.error(message),
|
||||
(message) => console.error(terminalText(message)),
|
||||
);
|
||||
return {
|
||||
video: info.path,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { terminalText } from "@hyperframes/core";
|
||||
import { defineCommand } from "../utils/defineCommand.js";
|
||||
import { readHarnessUsage } from "../utils/harnessUsage.js";
|
||||
|
||||
@@ -18,7 +19,8 @@ export default defineCommand({
|
||||
const harness = args.harness ?? detectHarness();
|
||||
const usage = await readHarnessUsage(harness);
|
||||
if (args.json) console.log(JSON.stringify(usage));
|
||||
else if (usage.status === "unknown") console.log(`Usage unknown (${usage.reason}).`);
|
||||
else if (usage.status === "unknown")
|
||||
console.log(`Usage unknown (${terminalText(usage.reason)}).`);
|
||||
else console.log(JSON.stringify(usage, null, 2));
|
||||
},
|
||||
});
|
||||
|
||||
@@ -160,9 +160,10 @@ describe("leftOutNotice", () => {
|
||||
|
||||
it("names the first five escaped, counts the rest and says how to keep them", () => {
|
||||
const leftOut = ["a\x1b[2J.png", "b.txt", "c.txt", "d.txt", "e.txt", "f.txt", "g.txt"];
|
||||
const notice = leftOutNotice("compare a.html", { leftOut, complete: false });
|
||||
const notice = leftOutNotice("compare a\x1b[2J\nb.html", { leftOut, complete: false });
|
||||
|
||||
expect(notice).not.toContain("\x1b");
|
||||
expect(notice).toMatch(/^compare a\\x1b\[2J\\x0ab\.html: left out /);
|
||||
expect(notice).toContain("a\\x1b[2J.png, b.txt, c.txt, d.txt, e.txt, and 2 more.");
|
||||
expect(notice).toContain("too large or too many");
|
||||
expect(notice).toContain("pass the project folder");
|
||||
|
||||
@@ -114,5 +114,5 @@ export function leftOutNotice(command: string, result: StagedFiles): string | nu
|
||||
result.leftOut.length > NAMES_SHOWN ? `, and ${result.leftOut.length - NAMES_SHOWN} more` : "";
|
||||
const named = shown.length > 0 ? ` left out ${shown.join(", ")}${more}.` : "";
|
||||
const partial = result.complete ? "" : " Some files were too large or too many to read in full.";
|
||||
return `${command}:${named}${partial} Only the files the page names in its own folder are served; pass the project folder to keep the rest.`;
|
||||
return `${terminalText(command)}:${named}${partial} Only the files the page names in its own folder are served; pass the project folder to keep the rest.`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user