CliConfig.fromYaml constructor
CliConfig.fromYaml(
- YamlMap map
Implementation
factory CliConfig.fromYaml(YamlMap map) {
return CliConfig(
providerKind: map['provider'] as String? ?? 'openai-completions',
modelId: map['model'] as String? ?? 'openai/gpt-4o-mini',
baseUrl: map['baseUrl'] as String? ?? 'https://openrouter.ai/api/v1',
mode: map['mode'] as String? ?? 'code',
approvalMode: map['approvalMode'] as String? ?? 'yolo',
allowedTools: switch (map['allowedTools']) {
final YamlList list => [for (final entry in list) '$entry'],
_ => const [],
},
// The prompts section is parsed strictly: unknown prompt names throw
// [ConfigException] instead of silently doing nothing.
promptOverrides: parsePromptOverrideMap(map['prompts']),
// The roles section is parsed strictly: schema errors throw
// [ConfigException] instead of silently resetting to defaults.
modelRoles: map['roles'] == null && map['modelOverrides'] == null
? null
: ModelRolesConfig.fromYaml(map),
// The ttsr section is parsed strictly too (bad rules must surface).
ttsr: map['ttsr'] == null
? null
: TtsrConfig.fromYaml(map['ttsr'], sourcePath: '~/.fah/config.yaml'),
);
}