compactiontypes

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package compactiontypes holds the compaction types that both the extension API and the compaction pipeline name: Pi's CompactionPreparation, CompactionSettings and FileOperations (core/compaction). It imports no coding package, so coding/extension can use them without an import cycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortedPaths

func SortedPaths(set map[string]struct{}) []string

SortedPaths returns the Set's paths in JavaScript sort order (UTF-16 code units).

Types

type CompactionPreparation

type CompactionPreparation struct {
	FirstKeptEntryID    string               `json:"firstKeptEntryId"`
	MessagesToSummarize []agent.AgentMessage `json:"messagesToSummarize"`
	TurnPrefixMessages  []agent.AgentMessage `json:"turnPrefixMessages"`
	IsSplitTurn         bool                 `json:"isSplitTurn"`
	TokensBefore        int                  `json:"tokensBefore"`
	PreviousSummary     string               `json:"previousSummary,omitempty"`
	FileOps             FileOperations       `json:"fileOps"`
	Settings            CompactionSettings   `json:"settings"`
}

CompactionPreparation is the output of PrepareCompaction. Mirrors upstream CompactionPreparation (compaction.ts:600).

Extensions receive it in session_before_compact, so the JSON keys are upstream's field names.

type CompactionSettings

type CompactionSettings struct {
	Enabled          bool `json:"enabled"`
	ReserveTokens    int  `json:"reserveTokens"`    // tokens reserved for response; default 16384
	KeepRecentTokens int  `json:"keepRecentTokens"` // tokens to keep from recent history; default 20000
}

CompactionSettings controls when and how compaction runs. Mirrors upstream CompactionSettings (compaction.ts:115).

type FileOperations

type FileOperations struct {
	Read    map[string]struct{}
	Written map[string]struct{}
	Edited  map[string]struct{}
}

FileOperations tracks files read/written/edited during a session segment. Mirrors upstream FileOperations (utils.ts): three Sets of paths.

func (FileOperations) MarshalJSON

func (ops FileOperations) MarshalJSON() ([]byte, error)

MarshalJSON carries each Set on the subprocess wire as a sorted string array.

Jump to

Keyboard shortcuts

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