/** * ANSI styling for action logs — the SDK's formatting vocabulary. * * The platform renders action output in a terminal-like frame that interprets * ANSI escapes: dim for supporting detail, cyan for identifiers and URLs, * green/red for outcomes, yellow for the things an operator should notice. * No HTML, no emojis — just a terminal being a terminal. Import from * "@nullplatform/plugin/term" to style your own messages; ctx.log applies the * base styling automatically. * * Honored convention: NO_COLOR (or a non-TTY consumer that sets it) turns * every helper into a pass-through, so logs stay readable anywhere. */ // Read at call time, not import time — tests and long-lived workers can flip it. const enabled = () => !process.env.NO_COLOR; const wrap = (open: string, close: string) => (s: string) => enabled() ? `\x1b[${open}m${s}\x1b[${close}m` : s; export const bold = wrap("1", "22"); export const dim = wrap("2", "22"); export const cyan = wrap("36", "39"); export const green = wrap("32", "39"); export const yellow = wrap("33", "39"); export const red = wrap("31", "39"); /** URLs read best cyan and stand alone at the end of a line. */ export const url = (u: string) => cyan(u); /** `label value` with the label dimmed and padded — aligned detail lines. */ export const kv = (label: string, value: string, pad = 10) => `${dim(label.padEnd(pad))}${value}`; /** Human elapsed time: 34s, 2m10s. */ export function elapsed(ms: number): string { const s = Math.round(ms / 1000); return s < 60 ? `${s}s` : `${Math.floor(s / 60)}m${String(s % 60).padStart(2, "0")}s`; } // Release marker: 3.1.0's publish never completed; this commit exists to cut // the next release with the exact same code paths. No behavioural change.