|
1 | 1 | import type { Logger } from "../logger" |
2 | | -import type { SessionStats, GCStats, PruningResult } from "../core/janitor" |
| 2 | +import type { SessionStats, GCStats } from "../core/janitor" |
3 | 3 | import type { ToolMetadata } from "../fetch-wrapper/types" |
4 | 4 | import { formatTokenCount } from "../tokenizer" |
5 | 5 | import { extractParameterKey } from "./display-utils" |
@@ -146,72 +146,6 @@ function buildDetailedMessage(data: NotificationData, workingDirectory?: string) |
146 | 146 | return message.trim() |
147 | 147 | } |
148 | 148 |
|
149 | | -export function formatPruningResultForTool( |
150 | | - result: PruningResult, |
151 | | - workingDirectory?: string |
152 | | -): string { |
153 | | - const lines: string[] = [] |
154 | | - lines.push(`Context pruning complete. Pruned ${result.prunedCount} tool outputs.`) |
155 | | - lines.push('') |
156 | | - |
157 | | - if (result.llmPrunedIds.length > 0) { |
158 | | - lines.push(`Semantically pruned (${result.llmPrunedIds.length}):`) |
159 | | - const toolsSummary = buildToolsSummary(result.llmPrunedIds, result.toolMetadata, workingDirectory) |
160 | | - lines.push(...formatToolSummaryLines(toolsSummary)) |
161 | | - } |
162 | | - |
163 | | - return lines.join('\n').trim() |
164 | | -} |
165 | | - |
166 | | -export function buildToolsSummary( |
167 | | - prunedIds: string[], |
168 | | - toolMetadata: Map<string, ToolMetadata>, |
169 | | - workingDirectory?: string |
170 | | -): Map<string, string[]> { |
171 | | - const toolsSummary = new Map<string, string[]>() |
172 | | - |
173 | | - for (const prunedId of prunedIds) { |
174 | | - const normalizedId = prunedId.toLowerCase() |
175 | | - const metadata = toolMetadata.get(normalizedId) |
176 | | - if (metadata) { |
177 | | - const toolName = metadata.tool |
178 | | - if (!toolsSummary.has(toolName)) { |
179 | | - toolsSummary.set(toolName, []) |
180 | | - } |
181 | | - |
182 | | - const paramKey = extractParameterKey(metadata) |
183 | | - if (paramKey) { |
184 | | - const displayKey = truncate(shortenPath(paramKey, workingDirectory), 80) |
185 | | - toolsSummary.get(toolName)!.push(displayKey) |
186 | | - } else { |
187 | | - toolsSummary.get(toolName)!.push('(default)') |
188 | | - } |
189 | | - } |
190 | | - } |
191 | | - |
192 | | - return toolsSummary |
193 | | -} |
194 | | - |
195 | | -export function formatToolSummaryLines( |
196 | | - toolsSummary: Map<string, string[]>, |
197 | | - indent: string = ' ' |
198 | | -): string[] { |
199 | | - const lines: string[] = [] |
200 | | - |
201 | | - for (const [toolName, params] of toolsSummary.entries()) { |
202 | | - if (params.length === 1) { |
203 | | - lines.push(`${indent}${toolName}: ${params[0]}`) |
204 | | - } else if (params.length > 1) { |
205 | | - lines.push(`${indent}${toolName} (${params.length}):`) |
206 | | - for (const param of params) { |
207 | | - lines.push(`${indent} ${param}`) |
208 | | - } |
209 | | - } |
210 | | - } |
211 | | - |
212 | | - return lines |
213 | | -} |
214 | | - |
215 | 149 | function truncate(str: string, maxLen: number = 60): string { |
216 | 150 | if (str.length <= maxLen) return str |
217 | 151 | return str.slice(0, maxLen - 3) + '...' |
|
0 commit comments