Skip to main content

Module classify

Module classify 

Source
Expand description

Command output classification and intelligent truncation. Command output classification and intelligent truncation.

This module is the core of oo’s context-efficient output handling. It analyzes command results and produces one of five Classification outcomes:

  • Failure: Non-zero exit codes → filtered error output (full output indexed for recall when the slice does not match it)
  • Passthrough: Small successful outputs (≤ 4 KiB, 4096 bytes) → verbatim
  • Success: Large successful outputs with pattern match → compressed summary
  • Bounded: Large Content/Unknown output → full output indexed, byte-bounded display
  • Large: Large Data output without pattern → indexed for recall

The classify function combines pattern matching with automatic command category detection to make intelligent decisions about how to present output.

Enums§

Classification
Command output classification result.
CommandCategory
Command category — determines default output handling when no pattern matches.

Constants§

DISPLAY_CAP
Total byte budget for the display slice of a bounded (Content/Unknown) output.
MIN_SAVINGS
Minimum savings (bytes) for the [saved …] indicator-line suffix.
SMALL_THRESHOLD
4 KiB (4096 bytes). Successful output of at most this many bytes passes through verbatim; larger output is classified.

Functions§

bounded_truncate
Byte-based truncation with UTF-8 char-boundary safety.
bounded_truncate_indexed
bounded_truncate with the marker chosen by whether the full output was indexed. When indexed is false the marker must not advertise oo recall, because there is nothing to recall.
classify
Classify command output using patterns and automatic category detection.
detect_category
Detect command category from command string.
label
Derive a short label from a command string.
smart_truncate
Smart truncation: first 60% + marker + last 40%, capped at MAX_LINES.