Skip to content

Commit ca1f35f

Browse files
committed
Add system prompt transformation hook for synthetic prompt injection
1 parent 83e4703 commit ca1f35f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Plugin } from "@opencode-ai/plugin"
22
import { getConfig } from "./lib/config"
33
import { Logger } from "./lib/logger"
4+
import { loadPrompt } from "./lib/prompt"
45
import { createSessionState } from "./lib/state"
56
import { createPruneTool } from "./lib/strategies"
67
import { createChatMessageTransformHandler, createEventHandler } from "./lib/hooks"
@@ -27,6 +28,10 @@ const plugin: Plugin = (async (ctx) => {
2728
})
2829

2930
return {
31+
"experimental.chat.system.transform": async (_input: unknown, output: { system: string[] }) => {
32+
const syntheticPrompt = loadPrompt("synthetic")
33+
output.system.push(syntheticPrompt)
34+
},
3035
"experimental.chat.messages.transform": createChatMessageTransformHandler(
3136
ctx.client,
3237
state,

lib/messages/prune.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export const prune = (
9292
messages: WithParts[]
9393
): void => {
9494
pruneToolOutputs(state, logger, messages)
95+
// more prune methods coming here
9596
}
9697

9798
const pruneToolOutputs = (

0 commit comments

Comments
 (0)