repositories / pi-ext
pi-ext
bugabingas pi extensions
owned by bugabinga
extensions/prune/src/types.ts
Raw/**
* prune — types
*/
// ─── Core Types ────────────────────────────────────────────────────────────────
export interface Message {
role:
| "user"
| "assistant"
| "tool"
| "toolResult"
| "bashExecution"
| "custom"
| "branchSummary"
| "compactionSummary";
content?: string | ContentPart[];
toolName?: string;
toolCallId?: string;
isError?: boolean;
thinking?: string;
redacted?: boolean;
}
export interface ContentPart {
type: "text" | "toolCall" | "thinking" | "image";
text?: string;
name?: string;
arguments?: Record<string, unknown>;
thinking?: string;
redacted?: boolean;
mimeType?: string;
}
// ─── Block Types ──────────────────────────────────────────────────────────────
export type BlockKind =
| "user"
| "assistant"
| "tool_call"
| "tool_result"
| "thinking";
export interface Block {
kind: BlockKind;
text: string;
sourceIndex: number;
name?: string;
args?: Record<string, unknown>;
isError?: boolean;
}
// ─── Extract Output ───────────────────────────────────────────────────────────
export interface ExtractOutput {
goals: string[];
scopeChanges: string[];
files: {
modified: Set<string>;
created: Set<string>;
read: Set<string>;
};
context: string[];
preferences: string[];
transcript: TranscriptEntry[];
}
export interface TranscriptEntry {
role: "user" | "assistant" | "error";
text: string;
tool?: string;
cmd?: string;
ref?: string;
count?: number;
}
// ─── Prune Output ────────────────────────────────────────────────────────────
export interface PruneOutput {
summary: string;
stats: PruneStats;
}
export interface PruneStats {
messagesIn: number;
messagesOut: number;
reduction: number;
elapsedMs: number;
}
// ─── Search Types ─────────────────────────────────────────────────────────────
export type SearchScope = "lineage" | "all";
export interface SearchInput {
query: string | RegExp;
scope?: SearchScope;
limit?: number;
expand?: number[];
}
export interface SearchResult {
index: number;
entry: Message;
role: "user" | "assistant" | "tool";
score: number;
context?: string;
}
// ─── Settings ────────────────────────────────────────────────────────────────
export interface PruneSettings {
overrideDefault?: boolean;
sectionLimit?: number;
transcriptLimit?: number;
toolCapPerTurn?: number;
debug?: boolean;
}