Converts buffered command output objects into serializable context entries.
Description
JSON payloads are decoded eagerly so parent command envelopes can expose nested structured output without re-encoding it as an escaped string.
Interfaces
Methods
Consumes a single top-level JSON document from a multi-document stream.
Decodes a stream that contains multiple JSON documents separated by whitespace.
Decodes a buffered output string when it contains JSON content.
Decodes structured output that is preceded by plain-text warnings or banners.
Finds the offset of the next possible JSON document opening token.
Normalizes decoded structured payloads produced by wrapped tooling.
public
process(
array<string, mixed>
$context) : array<string, mixed>
Parameters
$context
:
array<string, mixed>
Return values
Consumes a single top-level JSON document from a multi-document stream.
private
consumeJsonDocument(
string
$content,
int
&$offset) : string|null
Parameters
$content
:
string
Description
the buffered output contents
$offset
:
int
Description
the current stream offset, advanced past the document on success
Return values
Description
the extracted JSON document
Decodes a stream that contains multiple JSON documents separated by whitespace.
private
decodeJsonDocumentStream(
string
$content) : array<int, mixed>|null
Parameters
$content
:
string
Description
the buffered output contents
Return values
Description
the decoded JSON documents when the stream is valid
Decodes a buffered output string when it contains JSON content.
private
decodeStructuredOutput(
string
$content) : mixed
Parameters
$content
:
string
Description
the buffered output contents
Return values
Description
the decoded JSON payload or the original string
Decodes structured output that is preceded by plain-text warnings or banners.
private
decodeStructuredOutputAfterTextPreamble(
string
$content) : mixed
Description
Some tooling emits advisory text before a valid JSON payload even when a machine-readable format is requested. When the suffix starting at the first valid JSON token is fully decodable, the textual preamble SHALL be ignored so parent command envelopes remain parseable.
Parameters
$content
:
string
Description
the buffered output contents
Return values
Description
the decoded JSON payload when a valid structured suffix exists
private
extractBufferedOutput(OutputInterface
$output) : mixed
Parameters
$output
:
OutputInterface
Finds the offset of the next possible JSON document opening token.
private
findNextJsonDocumentOffset(
string
$content,
int
$offset) : int|null
Parameters
$content
:
string
Description
the buffered output contents
$offset
:
int
Description
the offset from which scanning SHALL start
Return values
Description
the offset of the next "{" or "[" token
Normalizes decoded structured payloads produced by wrapped tooling.
private
normalizeStructuredPayload(
mixed
$payload) : mixed
Parameters
$payload
:
mixed
Description
the decoded payload
Return values
Description
the normalized payload