emit

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package emit enforces the core invariant of every token-saving sofia tool: a tool that stands in for a standard command (cat, grep, …) must never cost MORE tokens than that command would. If the compact rendering is not actually smaller — or could not be produced at all — the tool returns the raw equivalent instead, so the agent always gets the cheaper of the two and never a hard error that forces it back to a manual `cat`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	UsedRaw     bool
	CompactToks int64
	RawToks     int64
}

Result reports which branch SmallerOf chose, for call-log telemetry (`sf history` can then show how often compression actually pays off).

func SmallerOf

func SmallerOf(w io.Writer, compact, raw []byte) (Result, error)

SmallerOf writes whichever of compact/raw costs fewer estimated tokens to w and reports the decision. Ties go to compact (the saver wins when equal). A nil raw means "no raw equivalent available" → compact is written as-is.

Jump to

Keyboard shortcuts

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