mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
tweak: better error message if no primary agents are enabled
This commit is contained in:
parent
ad6a5e6157
commit
9caaae6a18
2 changed files with 13 additions and 1 deletions
|
|
@ -32,7 +32,8 @@ export function FormatError(input: unknown) {
|
|||
}
|
||||
if (Config.InvalidError.isInstance(input))
|
||||
return [
|
||||
`Config file at ${input.data.path} is invalid` + (input.data.message ? `: ${input.data.message}` : ""),
|
||||
`Configuration is invalid${input.data.path && input.data.path !== "config" ? ` at ${input.data.path}` : ""}` +
|
||||
(input.data.message ? `: ${input.data.message}` : ""),
|
||||
...(input.data.issues?.map((issue) => "↳ " + issue.message + " " + issue.path.join(".")) ?? []),
|
||||
].join("\n")
|
||||
|
||||
|
|
|
|||
|
|
@ -141,6 +141,17 @@ export namespace Config {
|
|||
|
||||
if (!result.keybinds) result.keybinds = Info.shape.keybinds.parse({})
|
||||
|
||||
// Only validate if user has configured agents - if none configured, built-in agents will be used
|
||||
if (Object.keys(result.agent).length > 0) {
|
||||
const primaryAgents = Object.values(result.agent).filter((a) => a.mode !== "subagent" && !a.hidden && !a.disable)
|
||||
if (primaryAgents.length === 0) {
|
||||
throw new InvalidError({
|
||||
path: "config",
|
||||
message: "No primary agents are available. Please configure at least one agent with mode 'primary' or 'all'.",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
config: result,
|
||||
directories,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue