fix(cli): indicate an empty model list

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
This commit is contained in:
chrarnoldus
2026-06-10 15:16:00 +00:00
parent 9e2994ca6b
commit 2a6596b0c5
5 changed files with 44 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@kilocode/cli": patch
---
Indicate when no models are available in model-not-found errors.
+2 -1
View File
@@ -57,7 +57,7 @@ export function FormatError(input: unknown) {
return (input as ErrorLike).message ?? ""
}
// ProviderModelNotFoundError: { providerID: string, modelID: string, suggestions?: string[] }
// ProviderModelNotFoundError: { providerID: string, modelID: string, suggestions?: string[], modelsEmpty?: boolean } // kilocode_change
const providerModelNotFound = configData(input, "ProviderModelNotFoundError")
if (providerModelNotFound) {
const suggestions = Array.isArray(providerModelNotFound.suggestions)
@@ -66,6 +66,7 @@ export function FormatError(input: unknown) {
return [
`Model not found: ${providerModelNotFound.providerID}/${providerModelNotFound.modelID}`,
...(suggestions.length ? ["Did you mean: " + suggestions.join(", ")] : []),
...(providerModelNotFound.modelsEmpty === true ? ["No models are currently available."] : []), // kilocode_change
`Try: \`kilo models\` to list available models`, // kilocode_change
`Or check your config (opencode.json) provider/model names`,
].join("\n")
+5 -2
View File
@@ -998,6 +998,7 @@ export class ModelNotFoundError extends Schema.TaggedErrorClass<ModelNotFoundErr
providerID: ProviderID,
modelID: ModelID,
suggestions: Schema.optional(Schema.Array(Schema.String)),
modelsEmpty: Schema.optional(Schema.Boolean), // kilocode_change
cause: Schema.optional(Schema.Defect),
}) {
static isInstance(input: unknown): input is ModelNotFoundError {
@@ -1725,7 +1726,8 @@ export const layer = Layer.effect(
: fuzzysort
.go(providerID, Object.keys({ ...s.catalog, ...s.providers }), { limit: 3, threshold: -10000 })
.map((m) => m.target)
return yield* new ModelNotFoundError({ providerID, modelID, suggestions })
const empty = Object.values(s.providers).every((item) => Object.keys(item.models).length === 0) // kilocode_change
return yield* new ModelNotFoundError({ providerID, modelID, suggestions, modelsEmpty: empty }) // kilocode_change
}
const info = provider.models[modelID]
@@ -1734,7 +1736,8 @@ export const layer = Layer.effect(
const suggestions = current.length
? current
: modelSuggestions(s.catalog[providerID], modelID, runtimeFlags.enableExperimentalModels)
return yield* new ModelNotFoundError({ providerID, modelID, suggestions })
const empty = Object.values(s.providers).every((item) => Object.keys(item.models).length === 0) // kilocode_change
return yield* new ModelNotFoundError({ providerID, modelID, suggestions, modelsEmpty: empty }) // kilocode_change
}
return info
})
+2 -1
View File
@@ -1118,10 +1118,11 @@ NOTE: At any point in time through this workflow you should feel free to ask the
const err = Cause.squash(exit.cause)
if (Provider.ModelNotFoundError.isInstance(err)) {
const hint = err.suggestions?.length ? ` Did you mean: ${err.suggestions.join(", ")}?` : ""
const empty = err.modelsEmpty ? " No models are currently available." : "" // kilocode_change
yield* bus.publish(Session.Event.Error, {
sessionID,
error: new NamedError.Unknown({
message: `Model not found: ${err.providerID}/${err.modelID}.${hint}`,
message: `Model not found: ${err.providerID}/${err.modelID}.${hint}${empty}`, // kilocode_change
}).toObject(),
})
}
@@ -0,0 +1,30 @@
import { describe, expect, test } from "bun:test"
import { FormatError } from "@/cli/error"
describe("model not found errors", () => {
test("indicates when no models are available", () => {
const data = {
providerID: "anthropic",
modelID: "claude-sonnet-4",
modelsEmpty: true,
}
expect(FormatError({ name: "ProviderModelNotFoundError", data })).toContain(
"No models are currently available.",
)
expect(FormatError({ _tag: "ProviderModelNotFoundError", ...data })).toContain(
"No models are currently available.",
)
})
test("omits the indication when models are available", () => {
const error = FormatError({
_tag: "ProviderModelNotFoundError",
providerID: "anthropic",
modelID: "claude-sonnet-4",
modelsEmpty: false,
})
expect(error).not.toContain("No models are currently available.")
})
})