From c75860ddf3bf54fb0bd8c21df3ae95efe188f68c Mon Sep 17 00:00:00 2001 From: James Russo Date: Sat, 21 Nov 2026 18:49:19 +0000 Subject: [PATCH] fix(cli): show control characters as text in notices that repeat a failure reason (#8387) * fix(cli): show control characters as text in notices that repeat a failure reason Co-Authored-By: Claude Fable 5.2 * fix(cli): keep a usage hint on one line Co-Authored-By: Claude Fable 5.2 * fix(cli): show control characters as text in prompt-log notices that repeat a failure reason The source check now also reads clack.log calls. The five notices it found (play and present port messages, the file approval notice) go through terminalText. Co-Authored-By: Claude Fable 5.2 --------- Co-authored-by: Claude Fable 5.2 --- docs/packages/cli.mdx | 10 +- packages/cli/src/auth/oauth.ts | 5 +- packages/cli/src/browser/launch.ts | 7 +- packages/cli/src/cli.ts | 3 +- packages/cli/src/commands/play.ts | 4 +- packages/cli/src/commands/present.ts | 4 +- .../cli/src/printedFailureText.wiring.test.ts | 140 ++++++++++++++++++ packages/cli/src/renderSetupWorker.ts | 5 +- .../cli/src/server/followReceivedRecords.ts | 5 +- packages/cli/src/server/studioServer.ts | 15 +- packages/cli/src/telemetry/config.ts | 5 +- packages/cli/src/utils/checkBrowser.ts | 3 +- packages/cli/src/utils/desktopApp.ts | 4 +- packages/cli/src/utils/errorMessage.ts | 3 + packages/cli/src/utils/historyOwner.ts | 5 +- packages/cli/src/utils/outsideFileApproval.ts | 5 +- packages/cli/src/utils/toolContext.ts | 5 +- 17 files changed, 198 insertions(+), 30 deletions(-) create mode 100644 packages/cli/src/printedFailureText.wiring.test.ts diff --git a/docs/packages/cli.mdx b/docs/packages/cli.mdx index 586e5d6bad..8abb6ef3c7 100644 --- a/docs/packages/cli.mdx +++ b/docs/packages/cli.mdx @@ -53,7 +53,15 @@ the `timeline` edit commands use `--dir`. 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. The same lines show the Unicode marks that switch text direction +reason. So do the notices that repeat the reason something went wrong: the +`[studio]` lines of `preview`, the `Error:` line and its hint that `auth login` +prints when sign-in is not set up, the `Browser close failed` and +`Browser shutdown failed` lines, the port and `--remote-debugging-port` messages +of `play` and `present`, and the notices about telemetry settings, project +history, the received-files record, the media scan before a preview, the desktop +app project file, render priority, a file approval that could not be saved and +`HF_TOOL_CONTEXT` events. +The same lines show the Unicode marks that switch text direction (U+202A to U+202E and U+2066 to U+2069) and the line and paragraph separators (U+2028 and U+2029) as visible text such as `\u202e`. Right-to-left letters, the marks U+200E, U+200F and U+061C, and the zero-width characters (U+200B to U+200D diff --git a/packages/cli/src/auth/oauth.ts b/packages/cli/src/auth/oauth.ts index fcd90e0638..e0e270a4c1 100644 --- a/packages/cli/src/auth/oauth.ts +++ b/packages/cli/src/auth/oauth.ts @@ -1,4 +1,5 @@ import { failCommand } from "../utils/commandResult.js"; +import { terminalLines, terminalText } from "@hyperframes/core/terminal-text"; /** * OAuth 2.0 + PKCE driver for the HeyGen public OAuth flow. * @@ -128,8 +129,8 @@ export function assertOAuthConfiguredOrExit(): void { resolveClientId(); } catch (err) { if (isAuthError(err) && err.code === "OAUTH_NOT_CONFIGURED") { - console.error(`Error: ${err.message}`); - if (err.hint) console.error(err.hint); + console.error(`Error: ${terminalText(err.message)}`); + if (err.hint) console.error(terminalLines(err.hint)); failCommand(); } throw err; diff --git a/packages/cli/src/browser/launch.ts b/packages/cli/src/browser/launch.ts index 94c2dfa3ba..5bd53e83ca 100644 --- a/packages/cli/src/browser/launch.ts +++ b/packages/cli/src/browser/launch.ts @@ -12,12 +12,13 @@ import { explainChromeLaunchFailure } from "@hyperframes/engine/chrome-startup"; import type { Browser, LaunchOptions, Page, PuppeteerNode } from "puppeteer-core"; import { withHyperframesBrowserMarker } from "@hyperframes/core/browser-marker"; import { buildChromeLaunchEnv } from "@hyperframes/core/chrome-env"; +import { terminalLines } from "@hyperframes/core/terminal-text"; import { resolveCaptureBrowserGpuMode, type BrowserGpuMode, type ResolvedBrowserGpuMode, } from "./gpuPolicy.js"; -import { normalizeErrorMessage, notePageCrash } from "../utils/errorMessage.js"; +import { normalizeErrorMessage, notePageCrash, stackOrMessage } from "../utils/errorMessage.js"; import { requestCliExit } from "../utils/commandResult.js"; import { processIsAlive, terminateWindowsProcessTree } from "../utils/processTree.js"; import { chromeDescendants, reapChromeTree } from "./chromeTree.js"; @@ -55,7 +56,7 @@ function stopForSignal(signal: "SIGINT" | "SIGTERM"): void { void shutdown.then( () => requestCliExit(signal === "SIGINT" ? 130 : 143), (error: unknown) => { - console.error("Browser shutdown failed:", error); + console.error("Browser shutdown failed:", terminalLines(stackOrMessage(error))); requestCliExit(1); }, ); @@ -320,7 +321,7 @@ async function closedWithoutKill(browser: Browser): Promise { try { await Promise.race([ closeGracefully(browser).catch((error: unknown) => - console.warn("Browser close failed:", error), + console.warn("Browser close failed:", terminalLines(stackOrMessage(error))), ), grace, ]); diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index aaa7f925ee..99361b4380 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -713,8 +713,7 @@ async function executeCli(): Promise { if (!typed || !error.result.presented) { const message = error instanceof Error ? error.message : String(error); const oneLine = error instanceof CliUsageError || isCittyUsageError(error); - const shown = oneLine ? terminalText : terminalLines; - console.error(shown(message)); + console.error(oneLine ? terminalText(message) : terminalLines(message)); } if (usage && error.hint) console.error(terminalText(error.hint)); } diff --git a/packages/cli/src/commands/play.ts b/packages/cli/src/commands/play.ts index 1e5aa30591..a865124b64 100644 --- a/packages/cli/src/commands/play.ts +++ b/packages/cli/src/commands/play.ts @@ -98,7 +98,7 @@ export default defineCommand({ try { startPort = parsePort(args.port ?? "3003"); } catch (error) { - clack.log.error(normalizeErrorMessage(error)); + clack.log.error(terminalText(normalizeErrorMessage(error))); failUsage(); } const project = resolveProject(args.dir); @@ -126,7 +126,7 @@ export default defineCommand({ args["remote-debugging-port"] as string | undefined, ); } catch (err) { - clack.log.error((err as Error).message); + clack.log.error(terminalText((err as Error).message)); failUsage(); } diff --git a/packages/cli/src/commands/present.ts b/packages/cli/src/commands/present.ts index 4345dd4d4a..e32202a508 100644 --- a/packages/cli/src/commands/present.ts +++ b/packages/cli/src/commands/present.ts @@ -62,7 +62,7 @@ export default defineCommand({ try { startPort = parsePort(args.port ?? "3004"); } catch (error) { - clack.log.error(normalizeErrorMessage(error)); + clack.log.error(terminalText(normalizeErrorMessage(error))); failUsage(); } const project = resolveProject(args.dir); @@ -86,7 +86,7 @@ export default defineCommand({ args["remote-debugging-port"] as string | undefined, ); } catch (err) { - clack.log.error((err as Error).message); + clack.log.error(terminalText((err as Error).message)); failUsage(); } diff --git a/packages/cli/src/printedFailureText.wiring.test.ts b/packages/cli/src/printedFailureText.wiring.test.ts new file mode 100644 index 0000000000..7cbefbfce2 --- /dev/null +++ b/packages/cli/src/printedFailureText.wiring.test.ts @@ -0,0 +1,140 @@ +import { readdirSync, readFileSync } from "node:fs"; +import { join, relative, sep } from "node:path"; +import { fileURLToPath } from "node:url"; +import ts from "typescript"; +import { expect, it } from "vitest"; + +const SRC = fileURLToPath(new URL(".", import.meta.url)); + +const SHOWS_TEXT_AS_WRITTEN = new Set([ + "terminalText", + "terminalLines", + "terminalTextDeep", + "errorBox", + "stringify", + "formatJson", +]); +const WRITTEN_BY_CLI = new Set(["stepsWrittenByCli"]); +const NAMES_A_FAILURE = /^(e|err|error)$/; +const WRITES_TO_A_PIPE_ITS_PARENT_READS: Record = { + "renderSetupWorker.ts": "its last line is the failure record `cancellableProcess.ts` parses", + "utils/cancellableProcess.ts": "passes on its own worker's stderr, as an inherited stream would", + "whisper/sherpaWorker.ts": "`whisper/sherpa.ts` reads the prefixed line and builds the failure", +}; +const CONSOLE_PRINTS = new Set(["log", "error", "warn", "info", "debug"]); + +function sources(dir: string): string[] { + return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => { + const at = join(dir, entry.name); + if (entry.isDirectory()) return sources(at); + return /\.tsx?$/.test(entry.name) && !/\.(test|fixture|d)\.tsx?$/.test(entry.name) ? [at] : []; + }); +} + +const calleeName = (call: ts.CallExpression) => + ts.isPropertyAccessExpression(call.expression) + ? call.expression.name.text + : call.expression.getText(); + +function printsToTerminal(call: ts.CallExpression): boolean { + if (!ts.isPropertyAccessExpression(call.expression)) return false; + const target = call.expression.expression.getText(); + const method = call.expression.name.text; + if (target === "console") return CONSOLE_PRINTS.has(method); + if (target === "clack.log") return true; + return method === "write" && (target === "process.stderr" || target === "process.stdout"); +} + +const shownAsWritten = (node: ts.Node) => + (ts.isCallExpression(node) && SHOWS_TEXT_AS_WRITTEN.has(calleeName(node))) || + (ts.isPropertyAccessExpression(node) && WRITTEN_BY_CLI.has(node.name.text)); + +const namesValue = (node: ts.Node, names: Set) => + ts.isIdentifier(node) && + names.has(node.text) && + !(ts.isPropertyAccessExpression(node.parent) && node.parent.name === node); + +function readsRaw(node: ts.Node, names: Set): boolean { + if (shownAsWritten(node)) return false; + if (ts.isConditionalExpression(node)) + return readsRaw(node.whenTrue, names) || readsRaw(node.whenFalse, names); + if (namesValue(node, names)) return true; + return !!ts.forEachChild(node, (child) => readsRaw(child, names) || undefined); +} + +function caughtName(node: ts.Node): { name: string; body: ts.Node } | undefined { + if (ts.isCatchClause(node) && node.variableDeclaration) + return { name: node.variableDeclaration.name.getText(), body: node.block }; + if (!ts.isFunctionLike(node) || !("body" in node) || !node.body) return undefined; + const parameter = node.parameters.find( + (each) => ts.isIdentifier(each.name) && NAMES_A_FAILURE.test(each.name.text), + ); + return parameter && { name: parameter.name.getText(), body: node.body }; +} + +function rawPrints(body: ts.Node, caught: string, file: ts.SourceFile): number[] { + const names = new Set([caught]); + const lines: number[] = []; + const visit = (node: ts.Node): void => { + if ( + ts.isVariableDeclaration(node) && + ts.isIdentifier(node.name) && + node.initializer && + readsRaw(node.initializer, names) + ) + names.add(node.name.text); + if ( + ts.isCallExpression(node) && + printsToTerminal(node) && + node.arguments.some((argument) => readsRaw(argument, names)) + ) + lines.push(file.getLineAndCharacterOfPosition(node.getStart()).line + 1); + ts.forEachChild(node, visit); + }; + visit(body); + return lines; +} + +function rawPrintsOfCaughtFailures(name: string, text: string): string[] { + const file = ts.createSourceFile(name, text, ts.ScriptTarget.Latest, true); + const found = new Set(); + const visit = (node: ts.Node): void => { + const caught = caughtName(node); + if (caught) + for (const line of rawPrints(caught.body, caught.name, file)) found.add(`${name}:${line}`); + ts.forEachChild(node, visit); + }; + visit(file); + return [...found]; +} + +const fileOf = (site: string) => site.slice(0, site.lastIndexOf(":")); + +it("prints a caught failure only through terminalText, terminalLines or errorBox", () => { + const sites = sources(SRC).flatMap((path) => + rawPrintsOfCaughtFailures(relative(SRC, path).split(sep).join("/"), readFileSync(path, "utf8")), + ); + const files = new Set(sites.map(fileOf)); + expect(sites.filter((site) => !(fileOf(site) in WRITES_TO_A_PIPE_ITS_PARENT_READS))).toEqual([]); + expect(Object.keys(WRITES_TO_A_PIPE_ITS_PARENT_READS).filter((file) => !files.has(file))).toEqual( + [], + ); +}); + +it("finds a caught failure printed as it came, directly or through a local name", () => { + const found = rawPrintsOfCaughtFailures( + "sample.ts", + [ + "try { run(); } catch (err) {", + " const message = err instanceof Error ? err.message : String(err);", + " console.error(`Failed: ${message}`);", + " console.error(`Failed: ${terminalText(message)}`);", + " console.log(JSON.stringify({ error: message }));", + "}", + "work().catch((error) => process.stderr.write(String(error)));", + "work().catch((error) => process.stderr.write(terminalLines(String(error))));", + "work().catch((error) => clack.log.warn(`Not saved: ${error.message}`));", + ].join("\n"), + ); + expect(found).toEqual(["sample.ts:3", "sample.ts:7", "sample.ts:9"]); +}); diff --git a/packages/cli/src/renderSetupWorker.ts b/packages/cli/src/renderSetupWorker.ts index 593b3f407a..caa2676d29 100644 --- a/packages/cli/src/renderSetupWorker.ts +++ b/packages/cli/src/renderSetupWorker.ts @@ -3,6 +3,7 @@ import "./utils/envProxyFetch.js"; import "./utils/windowsExeSearch.js"; import { readFile, rm } from "node:fs/promises"; import { constants, setPriority } from "node:os"; +import { terminalText } from "@hyperframes/core/terminal-text"; import { lintHyperframeHtml } from "@hyperframes/lint"; import { runBrowserInstall } from "./browser/installRun.js"; import { ensureBrowser, releaseOwnedBrowserInstallLock } from "./browser/manager.js"; @@ -32,7 +33,9 @@ function setOwnPriority(priority: number, whatStaysNormal: string): void { } catch (error) { if (SANDBOX_REFUSED_PRIORITY.has((error as { info?: { code?: string } }).info?.code ?? "")) return; - process.stderr.write(`${whatStaysNormal} at normal priority: ${(error as Error).message}\n`); + process.stderr.write( + `${whatStaysNormal} at normal priority: ${terminalText((error as Error).message)}\n`, + ); } } diff --git a/packages/cli/src/server/followReceivedRecords.ts b/packages/cli/src/server/followReceivedRecords.ts index 6c06d66bd9..33d6a9e385 100644 --- a/packages/cli/src/server/followReceivedRecords.ts +++ b/packages/cli/src/server/followReceivedRecords.ts @@ -1,5 +1,6 @@ import { existsSync, statSync } from "node:fs"; import type { Context, Hono } from "hono"; +import { terminalText } from "@hyperframes/core/terminal-text"; import { requestSubPath } from "@hyperframes/studio-server"; import { resolveWritableWithinProject } from "@hyperframes/studio-server/safe-path"; import { @@ -24,7 +25,9 @@ const listAt = (value: unknown, key: string): unknown[] => isObject(value) && Array.isArray(value[key]) ? value[key] : []; const warn = (error: unknown) => - console.warn(`[studio] Could not update the received-files record: ${String(error)}`); + console.warn( + `[studio] Could not update the received-files record: ${terminalText(String(error))}`, + ); const busy = (c: Context) => c.json( diff --git a/packages/cli/src/server/studioServer.ts b/packages/cli/src/server/studioServer.ts index a61d91f51c..dcb3f13589 100644 --- a/packages/cli/src/server/studioServer.ts +++ b/packages/cli/src/server/studioServer.ts @@ -9,7 +9,8 @@ import { PREVIEW_NONCE_HEADER, previewProof, previewToken } from "@hyperframes/c import type { HttpBindings } from "@hono/node-server"; import { Hono, type Context } from "hono"; import { streamSSE } from "hono/streaming"; -import { realpath, terminalText } from "@hyperframes/core"; +import { realpath, terminalLines, terminalText } from "@hyperframes/core"; +import { stackOrMessage } from "../utils/errorMessage.js"; import { createReadStream, existsSync, @@ -279,7 +280,7 @@ async function downloadRemoteGifImageSources( } catch (err) { console.warn( "[Studio] Remote animated GIF prep skipped:", - err instanceof Error ? err.message : err, + terminalText(err instanceof Error ? err.message : String(err)), ); } }), @@ -395,7 +396,7 @@ async function getThumbnailBrowser( } catch (err) { console.warn( "[Studio] Failed to launch thumbnail browser:", - err instanceof Error ? err.message : err, + terminalText(err instanceof Error ? err.message : String(err)), ); _thumbnailBrowserInitializing = null; return null; @@ -557,7 +558,7 @@ export function createStudioServer(options: StudioServerOptions): StudioServer { return history; }) .catch((error: unknown) => { - console.warn(`[studio] Project history is off: ${String(error)}`); + console.warn(`[studio] Project history is off: ${terminalText(String(error))}`); if (error instanceof HistoryBusyError) ownerWaitMs = 0; if (error instanceof HistoryBusyError || error instanceof HistoryClosedError) histories.forget(projectDir); @@ -615,7 +616,7 @@ export function createStudioServer(options: StudioServerOptions): StudioServer { } catch (err) { const { isCompositionTooLargeError } = await import("@hyperframes/core/compiler"); if (isCompositionTooLargeError(err)) throw err; - console.error("[studio] Bundle failed:", err); + console.error("[studio] Bundle failed:", terminalLines(stackOrMessage(err))); return null; } }, @@ -641,7 +642,7 @@ export function createStudioServer(options: StudioServerOptions): StudioServer { outputDir: heifOutputDir, outputSrcPrefix: ".hyperframes/prepared-assets/heif", allowOutsideFiles, - onFailure: (error) => console.warn(`[studio] ${error.message}`), + onFailure: (error) => console.warn(`[studio] ${terminalText(error.message)}`), }); const prepared = await prepareAnimatedGifInputs(htmlWithJpegs, { projectDir: project.dir, @@ -935,7 +936,7 @@ export function createStudioServer(options: StudioServerOptions): StudioServer { if (!opts.signal.aborted) { console.warn( "[Studio] Thumbnail generation failed:", - err instanceof Error ? err.message : err, + terminalText(err instanceof Error ? err.message : String(err)), ); } return null; diff --git a/packages/cli/src/telemetry/config.ts b/packages/cli/src/telemetry/config.ts index 64320ce6d1..0d5f767291 100644 --- a/packages/cli/src/telemetry/config.ts +++ b/packages/cli/src/telemetry/config.ts @@ -2,6 +2,7 @@ import * as fs from "node:fs"; import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs"; import { join } from "node:path"; import { homedir } from "node:os"; +import { terminalText } from "@hyperframes/core/terminal-text"; import { randomUUID } from "node:crypto"; import { normalizeErrorMessage } from "../utils/errorMessage.js"; import { telemetryRuntimeOverride } from "./policy.js"; @@ -131,7 +132,7 @@ function warnSeedBackfillFailed(error: string | undefined): void { // all. `hyperframes doctor` still surfaces it on demand. if (telemetryRuntimeOverride() !== null) return; console.warn( - `[hyperframes] Could not persist telemetry config${error ? `: ${error}` : ""}. ` + + `[hyperframes] Could not persist telemetry config${error ? `: ${terminalText(String(error))}` : ""}. ` + "Canary cohort assignment will not be stable across runs.", ); } @@ -930,7 +931,7 @@ function warnSettingsLockedOnce(error: unknown): void { process.argv.some((arg) => arg === "--json" || arg.startsWith("--json=")) ) return; - console.error(`${(error as Error).message} (see \`hyperframes doctor\`).`); + console.error(`${terminalText((error as Error).message)} (see \`hyperframes doctor\`).`); } export function updateLocalModelConsent( diff --git a/packages/cli/src/utils/checkBrowser.ts b/packages/cli/src/utils/checkBrowser.ts index 57335488fb..282106e780 100644 --- a/packages/cli/src/utils/checkBrowser.ts +++ b/packages/cli/src/utils/checkBrowser.ts @@ -46,6 +46,7 @@ import { resolveAutoProxy } from "./projectConfig.js"; import { findStageProxyBox } from "./compositionViewport.js"; import { mediaUsedSeconds } from "./mediaUsedSeconds.js"; import type { PreviewProxyBox } from "@hyperframes/core"; +import { terminalText } from "@hyperframes/core/terminal-text"; import { injectTagsAtHeadStart } from "@hyperframes/core/compiler/html-document"; import { STUDIO_PREVIEW_CAPTURE_MODE, @@ -261,7 +262,7 @@ export async function preResolveHostileMediaProxies( codecMap = await scanProjectMediaCodecMap(projectDir, [{ html }]); } catch (err) { console.error( - `[hyperframes] media proxy pre-resolve: scan failed (${normalizeErrorMessage(err)})`, + `[hyperframes] media proxy pre-resolve: scan failed (${terminalText(normalizeErrorMessage(err))})`, ); return none; } diff --git a/packages/cli/src/utils/desktopApp.ts b/packages/cli/src/utils/desktopApp.ts index f15c81bda0..5278b1c06b 100644 --- a/packages/cli/src/utils/desktopApp.ts +++ b/packages/cli/src/utils/desktopApp.ts @@ -2,7 +2,7 @@ import { spawn, spawnSync } from "node:child_process"; import { existsSync, readdirSync, readFileSync } from "node:fs"; import { homedir } from "node:os"; import { basename, isAbsolute, join, relative, win32 } from "node:path"; -import { isHyperframesProject } from "@hyperframes/core"; +import { isHyperframesProject, terminalText } from "@hyperframes/core"; import { addCatchUpNote, noteHandoff, seenPath } from "./appHistory.js"; import { createProjectConfig } from "./projectConfig.js"; import { isCI } from "./attendedTerminal.js"; @@ -173,7 +173,7 @@ function markBareIndexAsProject(dir: string): void { createProjectConfig(dir); } catch (error) { console.warn( - `◇ Couldn't add hyperframes.json to ${dir}, so the app may not open it: ${error}`, + `◇ Couldn't add hyperframes.json to ${dir}, so the app may not open it: ${terminalText(String(error))}`, ); } } diff --git a/packages/cli/src/utils/errorMessage.ts b/packages/cli/src/utils/errorMessage.ts index bf3d0438cc..95a893e394 100644 --- a/packages/cli/src/utils/errorMessage.ts +++ b/packages/cli/src/utils/errorMessage.ts @@ -40,6 +40,9 @@ export function splitStepsWrittenByCli(message: string): { }; } +export const stackOrMessage = (error: unknown): string => + error instanceof Error ? (error.stack ?? error.message) : String(error); + export function normalizeErrorMessage(error: unknown): string { if (error instanceof Error) return namedAfterCrash(error.message); if (typeof error === "string") return error; diff --git a/packages/cli/src/utils/historyOwner.ts b/packages/cli/src/utils/historyOwner.ts index 70d2a0203a..dade37b780 100644 --- a/packages/cli/src/utils/historyOwner.ts +++ b/packages/cli/src/utils/historyOwner.ts @@ -1,6 +1,7 @@ import { randomUUID } from "node:crypto"; import { accessSync, constants } from "node:fs"; import { join, resolve } from "node:path"; +import { terminalText } from "@hyperframes/core/terminal-text"; import { DEFAULT_HISTORY_ROOT, HistoryBusyError, @@ -223,7 +224,7 @@ async function relistWrites(projectDir: string, entry: HistoryEntry | null): Pro if (!entry?.files.length) return; const { relistHistoryWrites } = await import("./receivedRecordFollow.js"); await relistHistoryWrites(projectDir, entry).catch((error: unknown) => - console.warn(`Could not update the received-files record: ${String(error)}`), + console.warn(`Could not update the received-files record: ${terminalText(String(error))}`), ); } @@ -373,7 +374,7 @@ export async function withReader( if (ran || !(error instanceof HistoryBusyError || unwritable)) throw error; if (unwritable) console.error( - `[hyperframes] Could not write this project's history (${(error as Error).message}); showing it as last recorded.`, + `[hyperframes] Could not write this project's history (${terminalText((error as Error).message)}); showing it as last recorded.`, ); } // Opening failed, so the task has not run; an open turn's marker is left as it is. diff --git a/packages/cli/src/utils/outsideFileApproval.ts b/packages/cli/src/utils/outsideFileApproval.ts index fa05cb92a1..ff4f2851fe 100644 --- a/packages/cli/src/utils/outsideFileApproval.ts +++ b/packages/cli/src/utils/outsideFileApproval.ts @@ -1,6 +1,7 @@ import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs"; import { dirname, resolve } from "node:path"; import { realFilePath } from "@hyperframes/studio-server/safe-path"; +import { terminalText } from "@hyperframes/core/terminal-text"; import * as clack from "../ui/prompts.js"; import { hyperframesConfigDir } from "./configDir.js"; import { @@ -90,7 +91,9 @@ export async function stageWithOutsideFileApproval( try { rememberOutsideFiles(projectDir, paths); } catch (error) { - clack.log.warn(`Could not remember the approval for next time: ${(error as Error).message}`); + clack.log.warn( + `Could not remember the approval for next time: ${terminalText((error as Error).message)}`, + ); } return run(); } diff --git a/packages/cli/src/utils/toolContext.ts b/packages/cli/src/utils/toolContext.ts index 4c6d44c12f..5c0cfe205a 100644 --- a/packages/cli/src/utils/toolContext.ts +++ b/packages/cli/src/utils/toolContext.ts @@ -1,5 +1,6 @@ import { appendFileSync } from "node:fs"; import { extname, isAbsolute, resolve } from "node:path"; +import { terminalText } from "@hyperframes/core/terminal-text"; const TOOL_CONTEXT_VERSION = 1; @@ -95,6 +96,8 @@ export function reportArtifacts( try { appendFileSync(context.events.path, lines.join("")); } catch (error) { - console.error(`HF_TOOL_CONTEXT events could not be written: ${(error as Error).message}`); + console.error( + `HF_TOOL_CONTEXT events could not be written: ${terminalText((error as Error).message)}`, + ); } }