Documentation
¶
Overview ¶
Package output provides UTF-8-safe byte budgeting, ANSI/CR terminal normalization, and root-cause command output compaction under Antigravity CLI's inline spill threshold.
Index ¶
- Constants
- func EffectiveInlineMaxBytes(explicit int) int
- func FitSectionsToByteBudget(sections []string, maxBytes int, sep string) string
- func FormatCommandOutput(p CommandFormatParams) string
- func HumanBytes(n int) string
- func MarshalPretty(val any) string
- func MarshalResultCompact(val any) string
- func MarshalResultForBudget(val any, budgetBytes int) string
- func NormalizeTerminalOutput(raw string) string
- func PageFooter(p Page, index, total, totalLines, size int, key string) string
- func Shape(v any) string
- func SliceUTF8Bytes(s string, maxBytes int) string
- func StripAnsi(s string) string
- func TruncateHeadTailBytes(s string, maxBytes int, hint string) string
- func TruncateWithByteNotice(s string, maxBytes int) string
- type CommandFormatParams
- type Page
Constants ¶
const DefaultInlineMaxBytes = 9600
DefaultInlineMaxBytes stays just below Antigravity CLI's ~9,888-byte inline truncation cliff so MCP responses never spill to output.txt by default.
const PageBytes = 8000
PageBytes is the default page size for long text: one page plus the response header stays under the 9.6KB inline budget (Antigravity spills larger MCP outputs to output.txt).
Variables ¶
This section is empty.
Functions ¶
func EffectiveInlineMaxBytes ¶
EffectiveInlineMaxBytes resolves explicit per-call maxOutputBytes, AGY_PTC_MAX_OUTPUT_BYTES env override, or DefaultInlineMaxBytes.
func FitSectionsToByteBudget ¶
FitSectionsToByteBudget distributes maxBytes across sections via water-filling so short sections stay intact.
func FormatCommandOutput ¶
func FormatCommandOutput(p CommandFormatParams) string
FormatCommandOutput formats command execution output cleanly, extracting focused errors on failure.
func MarshalPretty ¶
MarshalPretty renders a value as indented JSON (no HTML escaping) so it pages line by line.
func MarshalResultCompact ¶
MarshalResultCompact serializes value for budget; uses indented JSON when it fits comfortably and switches to compact JSON before truncating.
func MarshalResultForBudget ¶
MarshalResultForBudget serializes val as indented JSON if it fits within budgetBytes (and <= 6000 B), otherwise compacts whitespace first so medium-sized payloads fit inline without truncation. Uses SetEscapeHTML(false) so `<`, `>`, and `&` in code/URLs stay literal 1-byte characters instead of `\u003c`/`\u0026`.
func NormalizeTerminalOutput ¶
NormalizeTerminalOutput strips ANSI sequences and collapses carriage-return progress bar overwrites.
func PageFooter ¶
PageFooter tells the model where it is and how to continue, e.g. "[page 1/4 · lines 1-212 of 890 · next: print(state.page('__result_1', 2)) · last: state.page('__result_1', -1)]". When key is empty, the footer falls back to the keyless state.page(n) form.
func Shape ¶
Shape summarizes a value's top-level structure so the model can slice an auto-spilled result precisely next turn, e.g. `{files: array(120) of {path, line}, summary: string(3.2KB), stats: object(5)}`.
func SliceUTF8Bytes ¶
SliceUTF8Bytes truncates s cleanly on a valid UTF-8 rune boundary at <= maxBytes.
func TruncateHeadTailBytes ¶
TruncateHeadTailBytes keeps both the beginning and end of s within maxBytes.
func TruncateWithByteNotice ¶
TruncateWithByteNotice truncates s to <= maxBytes UTF-8 bytes, preserving line boundaries when practical.
Types ¶
type CommandFormatParams ¶
type CommandFormatParams struct {
Stdout string
Stderr string
ExitCode int
TimedOut bool
SpawnErr string
MaxBytes int
Compact bool
}
CommandFormatParams configures command output compaction.