Skip to main content
Version: v0.0.3

Function: unsafeInputSuffix()

unsafeInputSuffix(bytes, posture): string

Build the only value-bearing addition the CLI ever appends to a secondary (stderr) surface: a bounded, single-line excerpt of the offending input, shown iff --unsafe-show-values is set. Under the default value-free posture it returns the empty string, so a diagnostic stays value-free unless the user explicitly opted in. This is the single chokepoint the PHI-leak matrix pins.

Parameters

bytes

Uint8Array

The input the CLI is operating on (only the leading UNSAFE_EXCERPT_MAX bytes are considered).

posture

PhiPosture

The resolved PhiPosture.

Returns

string

"" under the value-free default; otherwise a [unsafe-show-values] … suffix carrying a bounded, newline-flattened prefix of bytes.

Example

import { unsafeInputSuffix, VALUE_FREE, SHOW_VALUES } from "@cosyte/cli";

const bytes = new TextEncoder().encode("bad message");
unsafeInputSuffix(bytes, VALUE_FREE); // => ""
unsafeInputSuffix(bytes, SHOW_VALUES); // => " [unsafe-show-values] offending input …: bad message"