Documentation
¶
Index ¶
- Constants
- Variables
- func BatchSlice[T any](items []T, batchSize int) [][]T
- func CIWarning(message string)
- func CopyToClipboard(text string) error
- func EnsureDir(dir string) error
- func EnvDefault(k, def string) string
- func FindTraceFile(traceID string, filename string) (string, error)
- func FindTuskRoot() string
- func FormatJSONDiff(expected, actual any) string
- func FormatJSONDiffPlain(expected, actual any) string
- func FormatJSONForDiff(v any) string
- func GenerateDeterministicHash(value any) string
- func GenerateSchemaAndHash(value any) (schema any, valueHash string, schemaHash string)
- func GetGitRootDir() (string, error)
- func GetLogsDir() string
- func GetPossibleTraceDirs() []string
- func GetTracesDir() string
- func GetTuskDir() string
- func GetTuskRoot() string
- func IsSoftLineBreak(line string) bool
- func IsTerminal() bool
- func JoinWrappedLines(lines []string) string
- func MarkNonWrappable(text string) string
- func ParseProtobufSpanFromJSON(jsonData []byte) (*core.Span, error)
- func ParseSpansFromFile(filename string, filter SpanFilter) ([]*core.Span, error)
- func PromptUserChoice(question string, options []string) int
- func ReduceByMatchImportance(value any, schema *core.JsonSchema) any
- func ReduceSchemaByMatchImportance(schema *core.JsonSchema) *core.JsonSchema
- func RemoveHeadersFromInputValue(inputValue any) any
- func RenderMarkdown(markdown string) string
- func RenderMarkdownWithWidth(markdown string, width int) string
- func ResolveTuskPath(path string) string
- func SetTracesDirOverride(dir string)
- func StripANSI(s string) string
- func StripAllMarkers(text string) string
- func StripNoWrapMarker(text string) string
- func StripSoftLineBreak(text string) string
- func TUICIMode() bool
- func TruncateWithEllipsis(text string, maxWidth int) string
- func WrapLine(text string, maxWidth int) []string
- func WrapLines(lines []string, maxWidth int) []string
- func WrapText(content string, maxWidth int) string
- func WriteToSystemClipboard(text string) error
- type ProgressBar
- type ProgressTracker
- type SpanFilter
Constants ¶
const ( TuskDirName = ".tusk" TracesSubDir = "traces" LogsSubDir = "logs" ConfigFileName = "config.yaml" )
const NoWrapMarker = "\x00NOWRAP\x00"
const SoftLineBreak = "\x00SOFT\x00"
SoftLineBreak marks a continuation line (join directly when copying, no newline) The space (if any) is preserved in the content itself
Variables ¶
var PossibleTraceDirs = []string{
".tusk/traces",
"traces",
"tmp",
".",
}
List of directories to search for trace files
Functions ¶
func BatchSlice ¶
BatchSlice splits a slice into batches of the specified size. The last batch may contain fewer elements if the slice length is not evenly divisible by batchSize.
func CIWarning ¶
func CIWarning(message string)
CIWarning emits a warning annotation visible in the CI provider's UI. On providers without annotation support, this is a no-op — the caller should log the message separately via log.Stderrln or similar.
Supported providers:
- GitHub Actions: ::warning:: annotation (shows in workflow summary)
- Azure Pipelines: ##vso[task.logissue] (shows in pipeline summary)
- Buildkite: buildkite-agent annotate --style warning (shows on build page)
- GitLab CI: ANSI yellow text (visible in job log, no annotation UI)
func CopyToClipboard ¶
CopyToClipboard copies text to the system clipboard. It tries OSC52 first (for remote terminals), then falls back to OS clipboard.
func EnvDefault ¶
func FindTraceFile ¶
FindTraceFile searches for a JSONL trace file containing the given trace ID. If filename is provided, it tries that first before searching
func FindTuskRoot ¶
func FindTuskRoot() string
FindTuskRoot traverses up the directory tree looking for a .tusk directory Returns the directory containing .tusk, or empty string if not found
func FormatJSONDiff ¶
FormatJSONDiff creates a git-style unified diff between two JSON values
func FormatJSONDiffPlain ¶ added in v0.2.8
FormatJSONDiffPlain creates a plain unified diff between two JSON values without ANSI colors or box borders. Suitable for writing to files consumed by coding agents.
func FormatJSONForDiff ¶
FormatJSONForDiff formats a JSON value with proper indentation for diff display
func GenerateDeterministicHash ¶
GenerateDeterministicHash creates a deterministic hash of any JSON-serializable value
func GenerateSchemaAndHash ¶
GenerateSchemaAndHash generates JSON schema and deterministic hash for any value
func GetGitRootDir ¶ added in v0.2.12
GetGitRootDir returns the root of the current git repository. Returns empty string and an error if not in a git repo.
func GetPossibleTraceDirs ¶
func GetPossibleTraceDirs() []string
GetPossibleTraceDirs returns the list of directories to search for trace files, preferring override first.
func GetTuskDir ¶
func GetTuskDir() string
GetTuskDir returns the .tusk directory path (either local or in home directory)
func GetTuskRoot ¶
func GetTuskRoot() string
GetTuskRoot returns the root directory containing .tusk, or current directory if not found
func IsSoftLineBreak ¶
IsSoftLineBreak checks if a line is a continuation from wrapping
func IsTerminal ¶
func IsTerminal() bool
func JoinWrappedLines ¶
JoinWrappedLines joins lines respecting soft line breaks, SoftLineBreak lines are joined directly
func MarkNonWrappable ¶
MarkNonWrappable adds an invisible marker to indicate text should not be wrapped
func ParseProtobufSpanFromJSON ¶
ParseProtobufSpanFromJSON parses a JSON line into a protobuf Span
func ParseSpansFromFile ¶
func ParseSpansFromFile(filename string, filter SpanFilter) ([]*core.Span, error)
ParseSpansFromFile reads a JSONL trace file and returns spans matching the filter. If the file is malformed, it returns an error.
func PromptUserChoice ¶
PromptUserChoice displays a question with numbered options and returns the index of the selected option. Returns 0 if input is invalid or empty (defaults to first option).
func ReduceByMatchImportance ¶
func ReduceByMatchImportance(value any, schema *core.JsonSchema) any
ReduceByMatchImportance returns a copy of 'value' keeping only fields with matchImportance != 0. Schema is a JsonSchema proto with optional per-field "matchImportance": 0|1 (default 1). Supports nested objects and arrays (uses 'items' schema for arrays if present).
func ReduceSchemaByMatchImportance ¶
func ReduceSchemaByMatchImportance(schema *core.JsonSchema) *core.JsonSchema
ReduceSchemaByMatchImportance returns a copy of the schema with only fields that have matchImportance != 0 Theoretically match importance could be a decimal, but we don't support that yet.
func RemoveHeadersFromInputValue ¶
RemoveHeadersFromInputValue removes non-critical headers for header-agnostic matching but preserves headers that affect response format like Accept and Content-Type
func RenderMarkdown ¶
func RenderMarkdownWithWidth ¶
RenderMarkdownWithWidth renders markdown with a specific word wrap width. Uses width of 80 as a fallback if width <= 0.
func ResolveTuskPath ¶
ResolveTuskPath resolves a path relative to the tusk root if it's relative, or returns it as-is if it's already absolute
func SetTracesDirOverride ¶
func SetTracesDirOverride(dir string)
SetTracesDirOverride sets an explicit traces directory to use.
func StripAllMarkers ¶
StripAllMarkers removes all internal markers from text
func StripNoWrapMarker ¶
StripNoWrapMarker removes the non-wrappable marker from text before display
func StripSoftLineBreak ¶
StripSoftLineBreak removes the soft line break marker
func TUICIMode ¶
func TUICIMode() bool
TUICIMode returns true if TUSK_TUI_CI_MODE=1 is set. This enables CI-friendly TUI mode: forces TUI without a TTY, skips terminal size warnings, and auto-exits on completion.
func TruncateWithEllipsis ¶
func WrapLine ¶
WrapLine wraps a single line of text to the specified width, trying to break at word boundaries This function is ANSI-aware and preserves color codes It avoids wrapping lines that appear to be formatted output (like diffs)
func WrapLines ¶
WrapLines wraps multiple lines to fit within the specified width Returns a slice of wrapped lines with SoftLineBreak markers on continuation lines NoWrapMarker is stripped from output
func WriteToSystemClipboard ¶
WriteToSystemClipboard writes text to the OS clipboard with proper UTF-8 encoding. On macOS, it sets __CF_USER_TEXT_ENCODING to force pbcopy to interpret input as UTF-8 (the default is Mac OS Roman, which garbles multi-byte Unicode characters).
Types ¶
type ProgressBar ¶
type ProgressBar struct {
// contains filtered or unexported fields
}
ProgressBar shows a progress bar based on current/total counts
func NewProgressBar ¶
func NewProgressBar(message string) *ProgressBar
NewProgressBar creates a new progress bar that outputs to stderr
func (*ProgressBar) Add ¶
func (p *ProgressBar) Add(count int)
Add increments the current count by the given amount
func (*ProgressBar) Finish ¶
func (p *ProgressBar) Finish(finalMessage string)
Finish stops the progress bar and shows a completion message
func (*ProgressBar) SetCurrent ¶
func (p *ProgressBar) SetCurrent(current int)
SetCurrent sets the current count directly
func (*ProgressBar) SetTotal ¶
func (p *ProgressBar) SetTotal(total int)
SetTotal sets the total count for the progress bar
func (*ProgressBar) Start ¶
func (p *ProgressBar) Start()
Start initializes the progress bar (shows empty bar)
func (*ProgressBar) Stop ¶
func (p *ProgressBar) Stop()
Stop clears the progress bar without a final message
type ProgressTracker ¶
type ProgressTracker struct {
// contains filtered or unexported fields
}
ProgressTracker handles progress reporting for paginated fetches
func NewProgressTracker ¶
func NewProgressTracker(message string, interactive, quiet bool) *ProgressTracker
func (*ProgressTracker) Finish ¶
func (pt *ProgressTracker) Finish(finalMessage string)
func (*ProgressTracker) SetTotal ¶
func (pt *ProgressTracker) SetTotal(total int)
func (*ProgressTracker) Stop ¶
func (pt *ProgressTracker) Stop()
func (*ProgressTracker) Update ¶
func (pt *ProgressTracker) Update(current int)
type SpanFilter ¶
SpanFilter is a function type for filtering spans during parsing