refactor: polish CLI theme + progress helpers

This commit is contained in:
Peter Steinberger
2026-01-08 05:58:43 +01:00
parent e758cccd46
commit b8a186fbd3
6 changed files with 59 additions and 25 deletions

View File

@@ -4,7 +4,7 @@ import {
type ModelScanResult,
scanOpenRouterModels,
} from "../../agents/model-scan.js";
import { withProgress } from "../../cli/progress.js";
import { withProgressTotals } from "../../cli/progress.js";
import { CONFIG_PATH_CLAWDBOT, loadConfig } from "../../config/config.js";
import type { RuntimeEnv } from "../../runtime.js";
import { formatMs, formatTokenK, updateConfig } from "./shared.js";
@@ -189,13 +189,13 @@ export async function modelsScanCommand(
storedKey = undefined;
}
}
const results = await withProgress(
const results = await withProgressTotals(
{
label: "Scanning OpenRouter models...",
indeterminate: false,
enabled: opts.json !== true,
},
async (progress) =>
async (update) =>
await scanOpenRouterModels({
apiKey: storedKey ?? undefined,
minParamB: minParams,
@@ -206,10 +206,12 @@ export async function modelsScanCommand(
probe,
onProgress: ({ phase, completed, total }) => {
if (phase !== "probe") return;
if (total <= 0) return;
const labelBase = probe ? "Probing models" : "Scanning models";
progress.setLabel(`${labelBase} (${completed}/${total})`);
progress.setPercent((completed / total) * 100);
update({
completed,
total,
label: `${labelBase} (${completed}/${total})`,
});
},
}),
);