MCPcopy Index your code
hub / github.com/Opencode-DCP/opencode-dynamic-context-pruning / reload

Method reload

lib/prompts/store.ts:346–393  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

344 }
345
346 reload(): void {
347 const nextPrompts = createBundledRuntimePrompts()
348
349 if (!this.customPromptsEnabled) {
350 this.runtimePrompts = nextPrompts
351 return
352 }
353
354 for (const definition of PROMPT_DEFINITIONS) {
355 const bundledSource = BUNDLED_EDITABLE_PROMPTS[definition.runtimeField]
356 const bundledEditable = toEditablePromptText(definition, bundledSource)
357 const bundledRuntime = wrapRuntimePromptContent(definition, bundledEditable)
358 const fallbackValue = bundledRuntime || bundledSource.trim()
359 let effectiveValue = fallbackValue
360
361 for (const candidate of this.getOverrideCandidates(definition.fileName)) {
362 const rawOverride = readFileIfExists(candidate.path)
363 if (rawOverride === null) {
364 continue
365 }
366
367 const editableOverride = toEditablePromptText(definition, rawOverride)
368 if (!editableOverride) {
369 this.logger.warn("Prompt override is empty or invalid after normalization", {
370 key: definition.key,
371 path: candidate.path,
372 })
373 continue
374 }
375
376 const wrappedOverride = wrapRuntimePromptContent(definition, editableOverride)
377 if (!wrappedOverride) {
378 this.logger.warn("Prompt override could not be wrapped for runtime", {
379 key: definition.key,
380 path: candidate.path,
381 })
382 continue
383 }
384
385 effectiveValue = wrappedOverride
386 break
387 }
388
389 nextPrompts[definition.runtimeField] = effectiveValue
390 }
391
392 this.runtimePrompts = nextPrompts
393 }
394
395 private getOverrideCandidates(fileName: string): PromptOverrideCandidate[] {
396 const candidates: PromptOverrideCandidate[] = []

Callers 6

constructorMethod · 0.95
createCompressRangeToolFunction · 0.80
print.tsFile · 0.80

Calls 6

getOverrideCandidatesMethod · 0.95
toEditablePromptTextFunction · 0.85
wrapRuntimePromptContentFunction · 0.85
readFileIfExistsFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected