UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

50 lines • 2.53 kB
/** * Shared utilities for compaction and branch summarization. */ import type { AgentMessage } from "@earendil-works/pi-agent-core"; import { type ImageContent, type Message, type ProviderNativeContent, type TextContent, type ThinkingContent, type ToolCall } from "@earendil-works/pi-ai"; export interface FileOperations { read: Set<string>; written: Set<string>; edited: Set<string>; } export declare function createFileOps(): FileOperations; /** * Extract file operations from tool calls in an assistant message, or from the nested calls * recorded on a tool result. */ export declare function extractFileOpsFromMessage(message: AgentMessage, fileOps: FileOperations): void; /** * Compute final file lists from file operations. * Returns readFiles (files only read, not modified) and modifiedFiles. */ export declare function computeFileLists(fileOps: FileOperations): { readFiles: string[]; modifiedFiles: string[]; }; /** * Format file operations as XML tags for summary. */ export declare function formatFileOperations(readFiles: string[], modifiedFiles: string[]): string; type SummaryContentBlock = TextContent | ImageContent | ThinkingContent | ToolCall | ProviderNativeContent; /** * Extract text from content that may retain provider-native replay blocks. * * Provider-native blocks must remain on the original assistant message for * same-provider replay, but are not part of pi-ai's portable `contentText` * contract. Normalize a filtered copy for summarization instead of casting or * mutating the persisted message. */ export declare function contentTextForSummary(content: string | readonly SummaryContentBlock[], separator?: string): string; /** * Serialize LLM messages to text for summarization. * This prevents the model from treating it as a conversation to continue. * Call convertToLlm() first to handle custom message types. * * Tool results are truncated to keep the summarization request within * reasonable token budgets. Full content is not needed for summarization. */ export declare function serializeConversation(messages: Message[]): string; export declare const SUMMARIZATION_SYSTEM_PROMPT = "You are a context summarization assistant. Your task is to read a conversation between a user and an AI assistant, then produce a structured summary following the exact format specified.\n\nDo NOT continue the conversation. Do NOT respond to any questions in the conversation. ONLY output the structured summary."; export {}; //# sourceMappingURL=utils.d.ts.map