MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / createPrompt

Function createPrompt

src/shared/support-prompt.ts:11–30  ·  view source on GitHub ↗
(template: string, params: PromptParams)

Source from the content-addressed store, hash-verified

9}
10
11export const createPrompt = (template: string, params: PromptParams): string => {
12 return template.replace(/\${(.*?)}/g, (_, key) => {
13 if (key === "diagnosticText") {
14 return generateDiagnosticText(params["diagnostics"] as any[])
15 // eslint-disable-next-line no-prototype-builtins
16 } else if (params.hasOwnProperty(key)) {
17 // Ensure the value is treated as a string for replacement
18 const value = params[key]
19 if (typeof value === "string") {
20 return value
21 } else {
22 // Convert non-string values to string for replacement
23 return String(value)
24 }
25 } else {
26 // If the placeholder key is not in params, replace with empty string
27 return ""
28 }
29 })
30}
31
32interface SupportPromptConfig {
33 template: string

Callers 1

support-prompt.tsFile · 0.85

Calls 3

generateDiagnosticTextFunction · 0.85
StringInterface · 0.70
replaceMethod · 0.65

Tested by

no test coverage detected