fix: group /model list output
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
- (nothing yet)
|
- WhatsApp: group `/model list` output by provider for scannability. (#456) - thanks @mcinteerj
|
||||||
|
|
||||||
## 2026.1.8
|
## 2026.1.8
|
||||||
|
|
||||||
|
|||||||
@@ -348,6 +348,7 @@ export async function handleDirectiveOnly(params: {
|
|||||||
}
|
}
|
||||||
const agentDir = resolveClawdbotAgentDir();
|
const agentDir = resolveClawdbotAgentDir();
|
||||||
const modelsPath = `${agentDir}/models.json`;
|
const modelsPath = `${agentDir}/models.json`;
|
||||||
|
const formatPath = (value: string) => shortenHomePath(value);
|
||||||
const authByProvider = new Map<string, string>();
|
const authByProvider = new Map<string, string>();
|
||||||
for (const entry of allowedModelCatalog) {
|
for (const entry of allowedModelCatalog) {
|
||||||
if (authByProvider.has(entry.provider)) continue;
|
if (authByProvider.has(entry.provider)) continue;
|
||||||
@@ -360,26 +361,40 @@ export async function handleDirectiveOnly(params: {
|
|||||||
}
|
}
|
||||||
const current = `${params.provider}/${params.model}`;
|
const current = `${params.provider}/${params.model}`;
|
||||||
const defaultLabel = `${defaultProvider}/${defaultModel}`;
|
const defaultLabel = `${defaultProvider}/${defaultModel}`;
|
||||||
const header =
|
const lines = [
|
||||||
current === defaultLabel
|
`Current: ${current}`,
|
||||||
? `Models (current: ${current}):`
|
`Default: ${defaultLabel}`,
|
||||||
: `Models (current: ${current}, default: ${defaultLabel}):`;
|
`Auth file: ${formatPath(resolveAuthStorePathForDisplay())}`,
|
||||||
const lines = [header];
|
];
|
||||||
if (resetModelOverride) {
|
if (resetModelOverride) {
|
||||||
lines.push(`(previous selection reset to default)`);
|
lines.push(`(previous selection reset to default)`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Group models by provider
|
||||||
|
const byProvider = new Map<string, typeof allowedModelCatalog>();
|
||||||
for (const entry of allowedModelCatalog) {
|
for (const entry of allowedModelCatalog) {
|
||||||
const label = `${entry.provider}/${entry.id}`;
|
const models = byProvider.get(entry.provider);
|
||||||
const aliases = aliasIndex.byKey.get(label);
|
if (models) {
|
||||||
const aliasSuffix =
|
models.push(entry);
|
||||||
aliases && aliases.length > 0
|
continue;
|
||||||
? ` (alias: ${aliases.join(", ")})`
|
}
|
||||||
: "";
|
byProvider.set(entry.provider, [entry]);
|
||||||
const nameSuffix =
|
}
|
||||||
entry.name && entry.name !== entry.id ? ` — ${entry.name}` : "";
|
|
||||||
const authLabel = authByProvider.get(entry.provider) ?? "missing";
|
// Iterate over provider groups
|
||||||
const authSuffix = ` — auth: ${authLabel}`;
|
for (const provider of byProvider.keys()) {
|
||||||
lines.push(`- ${label}${aliasSuffix}${nameSuffix}${authSuffix}`);
|
const models = byProvider.get(provider);
|
||||||
|
if (!models) continue;
|
||||||
|
const authLabel = authByProvider.get(provider) ?? "missing";
|
||||||
|
lines.push("");
|
||||||
|
lines.push(`[${provider}] auth: ${authLabel}`);
|
||||||
|
for (const entry of models) {
|
||||||
|
const label = `${entry.provider}/${entry.id}`;
|
||||||
|
const aliases = aliasIndex.byKey.get(label);
|
||||||
|
const aliasSuffix =
|
||||||
|
aliases && aliases.length > 0 ? ` (${aliases.join(", ")})` : "";
|
||||||
|
lines.push(` • ${label}${aliasSuffix}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return { text: lines.join("\n") };
|
return { text: lines.join("\n") };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user