Skip to content

Commit 6dd62af

Browse files
committed
fix: resolve TypeScript errors in config set and model-defaults
- config/set.ts: move hyphen alias resolution after null check, type resolvedKey as string explicitly - model-defaults.ts: use Config camelCase keys instead of ConfigFile snake_case keys
1 parent 594d6b7 commit 6dd62af

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/commands/config/set.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ export default defineCommand({
3333
const key = flags.key as string | undefined;
3434
const value = flags.value as string | undefined;
3535

36-
// Resolve hyphen aliases to underscore keys
37-
const resolvedKey = KEY_ALIASES[key] || key;
38-
3936
if (!key || value === undefined) {
4037
throw new CLIError(
4138
'--key and --value are required.',
@@ -44,6 +41,9 @@ export default defineCommand({
4441
);
4542
}
4643

44+
// Resolve hyphen aliases to underscore keys
45+
const resolvedKey: string = KEY_ALIASES[key] || key;
46+
4747
if (!VALID_KEYS.includes(resolvedKey)) {
4848
throw new CLIError(
4949
`Invalid config key "${key}". Valid keys: ${VALID_KEYS.join(', ')}`,

src/utils/model-defaults.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { Config, ConfigFile } from '../config/schema';
1+
import type { Config } from '../config/schema';
22

33
/**
44
* Resolve the model for a given modality.
5-
* Priority: --model flag > config file default > hardcoded fallback.
5+
* Priority: --model flag > config default > hardcoded fallback.
66
*/
77
export function resolveModel(
8-
modality: keyof Pick<ConfigFile, 'default_text_model' | 'default_speech_model' | 'default_video_model' | 'default_music_model'>,
8+
defaultKey: 'defaultTextModel' | 'defaultSpeechModel' | 'defaultVideoModel' | 'defaultMusicModel',
99
fallback: string,
1010
config: Config,
1111
flags: Record<string, unknown>,
@@ -14,8 +14,8 @@ export function resolveModel(
1414
if (typeof flags.model === 'string' && flags.model.length > 0) {
1515
return flags.model;
1616
}
17-
// 2. Config file default
18-
const configDefault = config[modality] as string | undefined;
17+
// 2. Config default (runtime, camelCase)
18+
const configDefault = config[defaultKey] as string | undefined;
1919
if (configDefault) return configDefault;
2020
// 3. Hardcoded fallback
2121
return fallback;

0 commit comments

Comments
 (0)