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
  • Passthrough: Small successful outputs (<4KB) → 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 KB — below this, output passes through verbatim.

Functions§

bounded_truncate
Byte-based truncation with UTF-8 char-boundary safety.
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.