Skip to content

Commit 207a84a

Browse files
authored
Merge pull request #81 from Tarquinen/chore/readme-and-cleanup
Update demo image and remove unused code
2 parents be94849 + 43b6b7a commit 207a84a

File tree

5 files changed

+2
-72
lines changed

5 files changed

+2
-72
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Automatically reduces token usage in OpenCode by removing obsolete tool outputs from conversation history.
66

7-
![DCP in action](dcp-demo.png)
7+
![DCP in action](dcp-demo3.png)
88

99
## Installation
1010

dcp-demo2.png

175 KB
Loading

dcp-demo3.png

108 KB
Loading

lib/state/id-mapping.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ export function getActualId(sessionId: string, numericId: number): string | unde
5959
return mapping?.numericToActual.get(numericId)
6060
}
6161

62-
export function clearSessionMapping(sessionId: string): void {
63-
sessionMappings.delete(sessionId)
64-
}
65-
6662
export function clearAllMappings(): void {
6763
sessionMappings.clear()
6864
}

lib/ui/notification.ts

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Logger } from "../logger"
2-
import type { SessionStats, GCStats, PruningResult } from "../core/janitor"
2+
import type { SessionStats, GCStats } from "../core/janitor"
33
import type { ToolMetadata } from "../fetch-wrapper/types"
44
import { formatTokenCount } from "../tokenizer"
55
import { extractParameterKey } from "./display-utils"
@@ -146,72 +146,6 @@ function buildDetailedMessage(data: NotificationData, workingDirectory?: string)
146146
return message.trim()
147147
}
148148

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-
215149
function truncate(str: string, maxLen: number = 60): string {
216150
if (str.length <= maxLen) return str
217151
return str.slice(0, maxLen - 3) + '...'

0 commit comments

Comments
 (0)