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

Function showConfigWarnings

lib/config.ts:611–654  ·  view source on GitHub ↗
(
    ctx: PluginInput,
    configPath: string,
    configData: Record<string, any>,
    isProject: boolean,
)

Source from the content-addressed store, hash-verified

609}
610
611function showConfigWarnings(
612 ctx: PluginInput,
613 configPath: string,
614 configData: Record<string, any>,
615 isProject: boolean,
616): void {
617 const invalidKeys = getInvalidConfigKeys(configData)
618 const typeErrors = validateConfigTypes(configData)
619
620 if (invalidKeys.length === 0 && typeErrors.length === 0) {
621 return
622 }
623
624 const configType = isProject ? "project config" : "config"
625 const messages: string[] = []
626
627 if (invalidKeys.length > 0) {
628 const keyList = invalidKeys.slice(0, 3).join(", ")
629 const suffix = invalidKeys.length > 3 ? ` (+${invalidKeys.length - 3} more)` : ""
630 messages.push(`Unknown keys: ${keyList}${suffix}`)
631 }
632
633 if (typeErrors.length > 0) {
634 for (const err of typeErrors.slice(0, 2)) {
635 messages.push(`${err.key}: expected ${err.expected}, got ${err.actual}`)
636 }
637 if (typeErrors.length > 2) {
638 messages.push(`(+${typeErrors.length - 2} more type errors)`)
639 }
640 }
641
642 setTimeout(() => {
643 try {
644 ctx.client.tui.showToast({
645 body: {
646 title: `DCP: ${configType} warning`,
647 message: `${configPath}\n${messages.join("\n")}`,
648 variant: "warning",
649 duration: 7000,
650 },
651 })
652 } catch {}
653 }, 7000)
654}
655
656const defaultConfig: PluginConfig = {
657 enabled: true,

Callers 1

getConfigFunction · 0.85

Calls 2

getInvalidConfigKeysFunction · 0.85
validateConfigTypesFunction · 0.85

Tested by

no test coverage detected