Files
kit/internal/extensions
Ed Zynda a55f6d3d9a feat: improved compaction with split-turn handling, file tracking, and non-destructive persistence
Rework the compaction system with several improvements modelled after
pi's approach:

Compaction engine (internal/compaction):
- Tool result truncation: cap tool result text at 2000 chars during
  serialisation to keep summarisation requests within token budgets
- Serialize tool calls and reasoning parts (previously only text)
- Split turn handling: when a single turn exceeds the keep budget,
  summarise the turn prefix separately and merge with history summary
- Cumulative file tracking: extract read/modified files from tool calls
  (read, write, edit, grep, find, ls) and carry forward across
  compactions via PreviousCompaction parameter
- Add IsSplitTurn, findTurnStart helpers and CutPoint, ReadFiles,
  ModifiedFiles fields to CompactionResult

Session tree (internal/session):
- New CompactionEntry type records summary, first-kept-entry-id, token
  stats, and file lists without deleting old messages
- BuildContext skips entries before the compaction boundary and injects
  the summary as a system message
- GetContextEntryIDs maps fantasy message indices to entry IDs for
  cut-point resolution
- GetLastCompaction retrieves prior file tracking state

Non-destructive compaction (pkg/kit):
- Compact now appends a CompactionEntry instead of clearing and
  rewriting the session — old messages remain on disk for history
- Extension hook (BeforeCompact) can now provide a custom Summary that
  replaces the LLM-generated one, in addition to cancelling

UI (internal/ui):
- Tree selector renders CompactionEntry nodes with info styling

Events & hooks (pkg/kit):
- CompactionEvent includes ReadFiles and ModifiedFiles
- BeforeCompactResult gains Summary field for extension-provided summaries
- Bridge updated to forward custom summaries from extensions
2026-03-22 17:14:50 +03:00
..