File tree Expand file tree Collapse file tree 2 files changed +5
-20
lines changed
Expand file tree Collapse file tree 2 files changed +5
-20
lines changed Original file line number Diff line number Diff line change 11// Generated prompts (from .md files via scripts/generate-prompts.ts)
22import { SYSTEM as SYSTEM_PROMPT } from "./_codegen/system.generated"
33import { NUDGE } from "./_codegen/nudge.generated"
4- import { COMPRESS as COMPRESS_TOOL_SPEC } from "./_codegen/compress.generated"
4+ import { COMPRESS } from "./_codegen/compress.generated"
5+
6+ export { COMPRESS as COMPRESS_TOOL_SPEC }
57
68export function renderSystemPrompt ( manual ?: boolean ) : string {
79 let result = SYSTEM_PROMPT
@@ -33,20 +35,3 @@ export function renderNudge(mode: NudgeMode = "frequency"): string {
3335
3436 return extractInstruction ( NUDGE , "context_management_required" )
3537}
36-
37- const PROMPTS : Record < string , string > = {
38- "compress-tool-spec" : COMPRESS_TOOL_SPEC ,
39- }
40-
41- export function loadPrompt ( name : string , vars ?: Record < string , string > ) : string {
42- let content = PROMPTS [ name ]
43- if ( ! content ) {
44- throw new Error ( `Prompt not found: ${ name } ` )
45- }
46- if ( vars ) {
47- for ( const [ key , value ] of Object . entries ( vars ) ) {
48- content = content . replace ( new RegExp ( `\\{\\{${ key } \\}\\}` , "g" ) , value )
49- }
50- }
51- return content
52- }
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import type { WithParts, CompressSummary } from "../state"
33import type { ToolContext } from "./types"
44import { ensureSessionInitialized } from "../state"
55import { saveSessionState } from "../state/persistence"
6- import { loadPrompt } from "../prompts"
6+ import { COMPRESS_TOOL_SPEC } from "../prompts"
77import { getCurrentParams , countAllMessageTokens , countTokens } from "../strategies/utils"
88import type { AssistantMessage } from "@opencode-ai/sdk/v2"
99import { findStringInMessages , collectToolIdsInRange , collectMessageIdsInRange } from "./utils"
@@ -12,7 +12,7 @@ import { buildCompressionGraphData, cacheSystemPromptTokens } from "../ui/utils"
1212import { prune as applyPruneTransforms } from "../messages/prune"
1313import { clog , C } from "../compress-logger"
1414
15- const COMPRESS_TOOL_DESCRIPTION = loadPrompt ( "compress-tool-spec" )
15+ const COMPRESS_TOOL_DESCRIPTION = COMPRESS_TOOL_SPEC
1616const COMPRESS_SUMMARY_PREFIX = "[Compressed conversation block]\n\n"
1717
1818export function createCompressTool ( ctx : ToolContext ) : ReturnType < typeof tool > {
You can’t perform that action at this time.
0 commit comments