MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / handleProviderList

Function handleProviderList

apps/kimi-code/src/cli/sub/provider.ts:165–204  ·  view source on GitHub ↗
(
  deps: ProviderDeps,
  opts: ListOptions,
)

Source from the content-addressed store, hash-verified

163}
164
165export async function handleProviderList(
166 deps: ProviderDeps,
167 opts: ListOptions,
168): Promise<void> {
169 const harness = deps.getHarness();
170 await harness.ensureConfigFile();
171 const config = await harness.getConfig();
172
173 if (opts.json) {
174 deps.stdout.write(
175 `${JSON.stringify({ providers: config.providers, models: config.models ?? {} }, null, 2)}\n`,
176 );
177 return;
178 }
179
180 const modelsByProvider = new Map<string, string[]>();
181 for (const [alias, model] of Object.entries(config.models ?? {})) {
182 const list = modelsByProvider.get(model.provider) ?? [];
183 list.push(alias);
184 modelsByProvider.set(model.provider, list);
185 }
186
187 const providerIds = Object.keys(config.providers).toSorted();
188 if (providerIds.length === 0) {
189 deps.stdout.write('No providers configured.\n');
190 return;
191 }
192
193 for (const id of providerIds) {
194 const provider = config.providers[id]!;
195 const aliases = modelsByProvider.get(id) ?? [];
196 const sourceLabel = providerSourceLabel(provider);
197 deps.stdout.write(
198 `${id} type=${provider.type} models=${String(aliases.length)} source=${sourceLabel}\n`,
199 );
200 }
201 if (config.defaultModel !== undefined) {
202 deps.stdout.write(`\nDefault model: ${config.defaultModel}\n`);
203 }
204}
205
206/**
207 * Fetches the models.dev-style public catalog and lists providers, or — when

Callers 2

provider.test.tsFile · 0.90
registerProviderCommandFunction · 0.85

Calls 8

providerSourceLabelFunction · 0.85
keysMethod · 0.80
getConfigMethod · 0.65
writeMethod · 0.65
getMethod · 0.65
setMethod · 0.65
ensureConfigFileMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected