Skip to content

Commit eaf25eb

Browse files
committed
cleanup: remove prompt loading indirection
1 parent 2399d1f commit eaf25eb

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

lib/prompts/index.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Generated prompts (from .md files via scripts/generate-prompts.ts)
22
import { SYSTEM as SYSTEM_PROMPT } from "./_codegen/system.generated"
33
import { 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

68
export 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-
}

lib/tools/compress.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { WithParts, CompressSummary } from "../state"
33
import type { ToolContext } from "./types"
44
import { ensureSessionInitialized } from "../state"
55
import { saveSessionState } from "../state/persistence"
6-
import { loadPrompt } from "../prompts"
6+
import { COMPRESS_TOOL_SPEC } from "../prompts"
77
import { getCurrentParams, countAllMessageTokens, countTokens } from "../strategies/utils"
88
import type { AssistantMessage } from "@opencode-ai/sdk/v2"
99
import { findStringInMessages, collectToolIdsInRange, collectMessageIdsInRange } from "./utils"
@@ -12,7 +12,7 @@ import { buildCompressionGraphData, cacheSystemPromptTokens } from "../ui/utils"
1212
import { prune as applyPruneTransforms } from "../messages/prune"
1313
import { clog, C } from "../compress-logger"
1414

15-
const COMPRESS_TOOL_DESCRIPTION = loadPrompt("compress-tool-spec")
15+
const COMPRESS_TOOL_DESCRIPTION = COMPRESS_TOOL_SPEC
1616
const COMPRESS_SUMMARY_PREFIX = "[Compressed conversation block]\n\n"
1717

1818
export function createCompressTool(ctx: ToolContext): ReturnType<typeof tool> {

0 commit comments

Comments
 (0)