-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ts
More file actions
43 lines (37 loc) · 1.06 KB
/
Copy pathconfig.ts
File metadata and controls
43 lines (37 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import {
readConfig,
writeConfig,
type DevmapConfig
} from "../utils/config.js";
import { output } from "../utils/output.js";
export type ConfigDependencies = {
loadConfig?: () => Promise<DevmapConfig | null>;
persistConfig?: (config: DevmapConfig) => Promise<void>;
};
export async function configModelCommand(
model: string,
dependencies: ConfigDependencies = {}
): Promise<void> {
const selectedModel = model.trim();
if (!selectedModel) {
output.error("Model name cannot be empty.");
return;
}
const loadConfig = dependencies.loadConfig ?? readConfig;
const persistConfig = dependencies.persistConfig ?? writeConfig;
const config = await loadConfig();
if (!config) {
output.error("DevMap is not configured yet.");
output.note("Run devmap init before changing the model.");
return;
}
await persistConfig({
...config,
model: selectedModel
});
output.success(
selectedModel === "auto"
? "Restored automatic command-based model routing."
: `Default model override set to ${selectedModel}.`
);
}