compress

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(repoRoot string, r Result, backupDir, timestamp string) (rulesPath, backupPath string, err error)

Apply writes the compressed content to <repoRoot>/COMMITBRIEF.md after backing the original up to <repoRoot>/.commitbrief/backups/<timestamp>.md. The backup directory is gitignored by the .commitbrief/ rule `commitbrief setup --local` adds.

func BackupTimestamp

func BackupTimestamp(now time.Time) string

BackupTimestamp returns the ISO-8601-ish stamp used in backup filenames. Format: 2026-05-26T14-30-00Z. Colons are replaced with dashes so the path is portable to Windows (which forbids `:` in filenames).

Types

type Level

type Level int
const (
	LevelBalanced Level = iota
	LevelLight
	LevelAggressive
)

func ParseLevel

func ParseLevel(s string) (Level, error)

func (Level) String

func (l Level) String() string

type Request

type Request struct {
	Level    Level
	Original string // raw COMMITBRIEF.md content
	Model    string
}

type Result

type Result struct {
	OriginalContent   string
	CompressedContent string
	OriginalChars     int
	CompressedChars   int
	OriginalTokens    int
	CompressedTokens  int
	Usage             provider.Usage
	Aborted           bool   // true if the compressed output is not smaller; original unchanged
	AbortReason       string // why we refused to apply
}

func Run

func Run(ctx context.Context, p provider.Provider, req Request) (Result, error)

Run sends the compression request to the provider, post-processes the response (strips common preambles and code-fence wrapping), and reports the savings. The caller is responsible for displaying the diff, asking for confirmation, and persisting the result via Apply.

func (Result) Savings

func (r Result) Savings() (percent float64, deltaTokens int)

Savings returns a per-review token reduction percentage and the absolute token delta. A 1000→400 compression yields (60.0, 600).

Jump to

Keyboard shortcuts

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