Skip to content

Commit 530540c

Browse files
authored
Merge pull request #253 from Opencode-DCP/merge-master-into-dev
Merge master into dev to resolve conflicts
2 parents 3b3de42 + b21cca3 commit 530540c

File tree

3 files changed

+8
-52
lines changed

3 files changed

+8
-52
lines changed

lib/messages/inject.ts

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
extractParameterKey,
88
buildToolIdList,
99
createSyntheticAssistantMessageWithToolPart,
10-
createSyntheticUserMessage,
1110
} from "./utils"
1211
import { getFilePathFromParameters, isProtectedFilePath } from "../protected-file-patterns"
1312
import { getLastUserMessage } from "../shared-utils"
@@ -140,32 +139,20 @@ export const insertPruneToolContext = (
140139

141140
const userInfo = lastUserMessage.info as UserMessage
142141
const providerID = userInfo.model.providerID
142+
const modelID = userInfo.model.modelID
143143
const isGitHubCopilot =
144144
providerID === "github-copilot" || providerID === "github-copilot-enterprise"
145+
const isAnthropic = modelID.includes("claude")
145146

146-
if (isGitHubCopilot) {
147+
if (isGitHubCopilot || isAnthropic) {
147148
const lastMessage = messages[messages.length - 1]
148149
if (lastMessage?.info?.role === "user") {
149150
return
150151
}
151152
}
152153

153-
logger.info("Injecting prunable-tools list", {
154-
providerID,
155-
isGitHubCopilot,
156-
injectionType: isGitHubCopilot ? "assistant-with-tool-part" : "user-message",
157-
})
158-
159-
const variant = state.variant ?? (lastUserMessage.info as UserMessage).variant
160-
if (isGitHubCopilot) {
161-
messages.push(
162-
createSyntheticAssistantMessageWithToolPart(
163-
lastUserMessage,
164-
prunableToolsContent,
165-
variant,
166-
),
167-
)
168-
} else {
169-
messages.push(createSyntheticUserMessage(lastUserMessage, prunableToolsContent, variant))
170-
}
154+
const variant = state.variant ?? userInfo.variant
155+
messages.push(
156+
createSyntheticAssistantMessageWithToolPart(lastUserMessage, prunableToolsContent, variant),
157+
)
171158
}

lib/messages/utils.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,6 @@ const SYNTHETIC_MESSAGE_ID = "msg_01234567890123456789012345"
77
const SYNTHETIC_PART_ID = "prt_01234567890123456789012345"
88
const SYNTHETIC_CALL_ID = "call_01234567890123456789012345"
99

10-
export const createSyntheticUserMessage = (
11-
baseMessage: WithParts,
12-
content: string,
13-
variant?: string,
14-
): WithParts => {
15-
const userInfo = baseMessage.info as UserMessage
16-
return {
17-
info: {
18-
id: SYNTHETIC_MESSAGE_ID,
19-
sessionID: userInfo.sessionID,
20-
role: "user",
21-
time: { created: Date.now() },
22-
agent: userInfo.agent || "code",
23-
model: {
24-
providerID: userInfo.model.providerID,
25-
modelID: userInfo.model.modelID,
26-
},
27-
...(variant !== undefined && { variant }),
28-
},
29-
parts: [
30-
{
31-
id: SYNTHETIC_PART_ID,
32-
sessionID: userInfo.sessionID,
33-
messageID: SYNTHETIC_MESSAGE_ID,
34-
type: "text",
35-
text: content,
36-
},
37-
],
38-
}
39-
}
40-
4110
export const createSyntheticAssistantMessageWithToolPart = (
4211
baseMessage: WithParts,
4312
content: string,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://json.schemastore.org/package.json",
33
"name": "@tarquinen/opencode-dcp",
4-
"version": "1.1.6",
4+
"version": "1.1.7-beta.1",
55
"type": "module",
66
"description": "OpenCode plugin that optimizes token usage by pruning obsolete tool outputs from conversation context",
77
"main": "./dist/index.js",

0 commit comments

Comments
 (0)