|
1 | 1 | import type { SessionState, WithParts } from "../../state" |
2 | 2 | import type { PluginConfig } from "../../config" |
3 | | -import { renderMessagePriorityGuidance } from "../../prompts/message-priority-guidance" |
| 3 | +import { |
| 4 | + appendGuidanceToDcpTag, |
| 5 | + buildCompressedBlockGuidance, |
| 6 | + renderMessagePriorityGuidance, |
| 7 | +} from "../../prompts/extensions/nudge" |
4 | 8 | import type { RuntimePrompts } from "../../prompts/store" |
5 | 9 | import type { UserMessage } from "@opencode-ai/sdk/v2" |
6 | 10 | import { |
@@ -188,38 +192,6 @@ export function addAnchor( |
188 | 192 | return anchorMessageIds.size !== previousSize |
189 | 193 | } |
190 | 194 |
|
191 | | -export function buildCompressedBlockGuidance(state: SessionState): string { |
192 | | - const refs = Array.from(state.prune.messages.activeBlockIds) |
193 | | - .filter((id) => Number.isInteger(id) && id > 0) |
194 | | - .sort((a, b) => a - b) |
195 | | - .map((id) => `b${id}`) |
196 | | - const blockCount = refs.length |
197 | | - const blockList = blockCount > 0 ? refs.join(", ") : "none" |
198 | | - |
199 | | - return [ |
200 | | - "Compressed block context:", |
201 | | - `- Active compressed blocks in this session: ${blockCount} (${blockList})`, |
202 | | - "- If your selected compression range includes any listed block, include each required placeholder exactly once in the summary using \`(bN)\`.", |
203 | | - ].join("\n") |
204 | | -} |
205 | | - |
206 | | -function appendGuidanceToDcpTag(nudgeText: string, guidance: string): string { |
207 | | - if (!guidance.trim()) { |
208 | | - return nudgeText |
209 | | - } |
210 | | - |
211 | | - const closeTag = "</dcp-system-reminder>" |
212 | | - const closeTagIndex = nudgeText.lastIndexOf(closeTag) |
213 | | - |
214 | | - if (closeTagIndex === -1) { |
215 | | - return nudgeText |
216 | | - } |
217 | | - |
218 | | - const beforeClose = nudgeText.slice(0, closeTagIndex).trimEnd() |
219 | | - const afterClose = nudgeText.slice(closeTagIndex) |
220 | | - return `${beforeClose}\n\n${guidance}\n${afterClose}` |
221 | | -} |
222 | | - |
223 | 195 | function buildMessagePriorityGuidance( |
224 | 196 | messages: WithParts[], |
225 | 197 | compressionPriorities: CompressionPriorityMap | undefined, |
|
0 commit comments