MCPcopy Create free account
hub / github.com/anus-dev/ANUS / getEffectiveValue

Function getEffectiveValue

packages/cli/src/utils/settingsUtils.ts:114–140  ·  view source on GitHub ↗
(
  key: string,
  settings: Settings,
  mergedSettings: Settings,
)

Source from the content-addressed store, hash-verified

112 * Always returns a value (never undefined) - falls back to default if not set anywhere
113 */
114export function getEffectiveValue(
115 key: string,
116 settings: Settings,
117 mergedSettings: Settings,
118): SettingDefinition['default'] {
119 const definition = getSettingDefinition(key);
120 if (!definition) {
121 return undefined;
122 }
123
124 const path = key.split('.');
125
126 // Check the current scope's settings first
127 let value = getNestedValue(settings as Record<string, unknown>, path);
128 if (value !== undefined) {
129 return value as SettingDefinition['default'];
130 }
131
132 // Check the merged settings for an inherited value
133 value = getNestedValue(mergedSettings as Record<string, unknown>, path);
134 if (value !== undefined) {
135 return value as SettingDefinition['default'];
136 }
137
138 // Return default value if no value is set anywhere
139 return definition.default;
140}
141
142/**
143 * Get all setting keys from the schema

Callers 2

getSettingValueFunction · 0.85

Calls 2

getSettingDefinitionFunction · 0.85
getNestedValueFunction · 0.85

Tested by

no test coverage detected