tee

package
v0.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package tee provides raw output recovery for command failures.

The tee system saves unfiltered command output to disk when commands fail, allowing LLMs to access the full output without re-executing the command. This is especially useful for debugging failed tests or builds.

Based on RTK's tee system, ported to Go for TokMan.

Index

Constants

View Source
const (
	// MinTeeSize is the minimum output size to tee (smaller outputs don't need recovery).
	MinTeeSize = 500

	// DefaultMaxFiles is the default maximum number of tee files to keep.
	DefaultMaxFiles = 20

	// DefaultMaxFileSize is the default maximum file size (1MB).
	DefaultMaxFileSize = 1_048_576
)

Variables

This section is empty.

Functions

func CleanupTeeFiles added in v0.28.0

func CleanupTeeFiles(maxAge time.Duration) (int, error)

CleanupTeeFiles removes all tee files older than the specified duration.

func ForceTeeHint added in v0.28.0

func ForceTeeHint(raw string, commandSlug string) string

ForceTeeHint forces tee output regardless of exit code (used when filters truncate). Always writes file if size >= MinTeeSize and tee is enabled. Returns hint string if file was written, empty string if skipped/disabled.

Used by filters when FilterResult.truncated = true, ensuring the LLM has access to full untruncated output via the hint path.

func GetTeeDir added in v0.28.0

func GetTeeDir() (string, error)

GetTeeDir returns the current tee directory path. Useful for displaying to users or for testing.

func TeeAndHint added in v0.28.0

func TeeAndHint(raw string, commandSlug string, exitCode int) string

TeeAndHint writes raw output to a tee file and returns a formatted hint. Returns the hint string if file was written, empty string if skipped.

Example output: "[full output: ~/.local/share/tokman/tee/1234567890_cargo_test.log]"

func TeeRaw added in v0.28.0

func TeeRaw(raw string, commandSlug string, exitCode int) string

TeeRaw writes raw output to a tee file if conditions are met. Returns the file path on success, empty string if skipped/failed.

This is the main entry point for tee functionality. It checks: - TOKMAN_TEE=0 env override (disables tee) - TOKMAN_TEE_MODE env override (failures/always/never) - Config enabled flag - Tee mode (failures/always/never) - Output size >= MinTeeSize

func WriteAndHint

func WriteAndHint(content string, commandSlug string, exitCode int) string

WriteAndHint writes content to a tee file and returns a hint message. This is the legacy API that maintains backward compatibility. For new code, use TeeAndHint instead.

Types

type TeeConfig added in v0.28.0

type TeeConfig struct {
	Enabled     bool    `toml:"enabled" mapstructure:"enabled"`
	Mode        TeeMode `toml:"mode" mapstructure:"mode"`
	MaxFiles    int     `toml:"max_files" mapstructure:"max_files"`
	MaxFileSize int     `toml:"max_file_size" mapstructure:"max_file_size"`
	Directory   string  `toml:"directory,omitempty" mapstructure:"directory"`
}

TeeConfig holds configuration for the tee feature.

func DefaultTeeConfig added in v0.28.0

func DefaultTeeConfig() TeeConfig

DefaultTeeConfig returns the default tee configuration.

type TeeFileInfo added in v0.28.0

type TeeFileInfo struct {
	Path    string
	Name    string
	ModTime time.Time
	Size    int64
}

TeeFileInfo represents information about a tee file.

func ListTeeFiles added in v0.28.0

func ListTeeFiles() ([]TeeFileInfo, error)

ListTeeFiles returns a list of existing tee files with their paths and modification times.

type TeeMode added in v0.28.0

type TeeMode string

TeeMode controls when tee writes files.

const (
	// TeeModeFailures only tees on command failure (default).
	TeeModeFailures TeeMode = "failures"
	// TeeModeAlways always tees output regardless of exit code.
	TeeModeAlways TeeMode = "always"
	// TeeModeNever disables tee entirely.
	TeeModeNever TeeMode = "never"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL