mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
refactor: address the comments
This commit is contained in:
@@ -145,8 +145,9 @@ export async function handle(args: ArgumentsCamelCase) {
|
||||
}
|
||||
|
||||
const json = args.output === "json"
|
||||
const structured = json || args.output === "md"
|
||||
|
||||
if (!args.quiet && !json) {
|
||||
if (!args.quiet && !structured) {
|
||||
UI.println(`${color(UI.Style.TEXT_INFO)}Starting roll call for models with prompt: "${args.prompt}"${color(UI.Style.TEXT_NORMAL)}`)
|
||||
UI.println(
|
||||
`${color(UI.Style.TEXT_INFO)}Timeout per model: ${args.timeout}ms, Parallel calls: ${args.parallel}${color(UI.Style.TEXT_NORMAL)}`,
|
||||
@@ -175,13 +176,13 @@ export async function handle(args: ArgumentsCamelCase) {
|
||||
)
|
||||
|
||||
if (models.length === 0) {
|
||||
if (!args.quiet && !json) UI.println(`${color(UI.Style.TEXT_WARNING)}No models to test after filtering.${color(UI.Style.TEXT_NORMAL)}`)
|
||||
if (!args.quiet && !structured) UI.println(`${color(UI.Style.TEXT_WARNING)}No models to test after filtering.${color(UI.Style.TEXT_NORMAL)}`)
|
||||
if (json) console.log(JSON.stringify([], null, 2))
|
||||
process.exitCode = 1
|
||||
return
|
||||
}
|
||||
|
||||
if (!args.quiet && !json) {
|
||||
if (!args.quiet && !structured) {
|
||||
UI.println(`${color(UI.Style.TEXT_INFO)}Prompting ${models.length} models...${color(UI.Style.TEXT_NORMAL)}`)
|
||||
}
|
||||
|
||||
@@ -196,7 +197,7 @@ export async function handle(args: ArgumentsCamelCase) {
|
||||
|
||||
results.push({ model: name, ...result })
|
||||
|
||||
if (!args.verbose || args.quiet || json) return
|
||||
if (!args.verbose || args.quiet || structured) return
|
||||
if (result.access) {
|
||||
UI.println(`${color(UI.Style.TEXT_SUCCESS)}✔${color(UI.Style.TEXT_NORMAL)} ${name} - ${result.latency}ms`)
|
||||
return
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { test, expect, describe } from "bun:test"
|
||||
import type { Provider } from "../../../src/provider/provider"
|
||||
import { formatTable, formatMarkdown, isTextModel } from "../../../src/kilocode/cli/cmd/roll-call"
|
||||
import { formatTable, formatMarkdown, handle, isTextModel } from "../../../src/kilocode/cli/cmd/roll-call"
|
||||
import { Provider } from "../../../src/provider/provider"
|
||||
|
||||
const base = {
|
||||
input: { text: false, audio: false, image: false, video: false, pdf: false },
|
||||
@@ -129,3 +130,34 @@ describe("formatMarkdown", () => {
|
||||
expect(md.split("\n")[2].match(/(?<!\\)\|/g)?.length).toBe(5)
|
||||
})
|
||||
})
|
||||
|
||||
describe("handle", () => {
|
||||
test("does not print progress before markdown output", async () => {
|
||||
const original = Provider.list
|
||||
const logs: string[] = []
|
||||
const print = console.log
|
||||
|
||||
Provider.list = async () => ({})
|
||||
console.log = (msg?: unknown) => {
|
||||
logs.push(String(msg))
|
||||
}
|
||||
|
||||
try {
|
||||
await handle({
|
||||
prompt: "Hello",
|
||||
timeout: 1,
|
||||
filter: "test",
|
||||
parallel: 1,
|
||||
output: "md",
|
||||
verbose: true,
|
||||
quiet: false,
|
||||
})
|
||||
} finally {
|
||||
Provider.list = original
|
||||
console.log = print
|
||||
process.exitCode = undefined
|
||||
}
|
||||
|
||||
expect(logs).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user