buffer

package
v0.17.4 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package buffer tracks which lines of a file the agent changed and the line delta of one diff. The per-turn content accumulator is internal/turnlog.

Index

Constants

View Source
const DefaultOutputCap = 64 * 1024

DefaultOutputCap is the shared byte budget for subprocess output buffers: a 200×50 screen with heavy ANSI.

Variables

This section is empty.

Functions

func LineDelta

func LineDelta(oldText, newText string) (added, removed int)

LineDelta reports how many lines a diff added and removed. KAS sends whole-file text, so a newline count reported whole-file churn for a one-line edit. added and removed derive from the LCS length; trimming the common prefix and suffix keeps that cheap.

Types

type LineRange

type LineRange struct {
	Kind      string `json:"kind"`
	StartLine int    `json:"start_line"`
	EndLine   int    `json:"end_line"`
	Turn      int    `json:"turn"`
}

LineRange is a range of lines modified by the agent.

type LineTracker

type LineTracker struct {
	// contains filtered or unexported fields
}

LineTracker tracks per-file line changes across all chats.

func NewLineTracker

func NewLineTracker() *LineTracker

NewLineTracker creates a new LineTracker.

func (*LineTracker) Clear

func (lt *LineTracker) Clear(chatID marotte.ChatID)

Clear removes all tracking data for a chat.

func (*LineTracker) Get

func (lt *LineTracker) Get(chatID marotte.ChatID, filePath string) []LineRange

Get returns a copy of the line ranges for a file in a chat: the HTTP handler reads after the lock is released while Record keeps appending to the same key.

func (*LineTracker) Record

func (lt *LineTracker) Record(chatID marotte.ChatID, filePath string, r LineRange)

Record adds a line range for a file change. A LineRange, not three adjacent ints: a silent transposition would invert the gutter range or corrupt the eviction key, since the heap orders files by lastTurn.

func (*LineTracker) RecordFromDiffs

func (lt *LineTracker) RecordFromDiffs(chatID marotte.ChatID, diffs []marotte.ToolDiff, turn int, kind string)

RecordFromDiffs records one range per diff hunk, in new-text line numbers, so KAS's whole-file NewText does not mark every line. A whole-file rewrite yields one full span.

Jump to

Keyboard shortcuts

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