Skip to content

Commit 9caaae6

Browse files
committed
tweak: better error message if no primary agents are enabled
1 parent ad6a5e6 commit 9caaae6

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/opencode/src/cli/error.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export function FormatError(input: unknown) {
3232
}
3333
if (Config.InvalidError.isInstance(input))
3434
return [
35-
`Config file at ${input.data.path} is invalid` + (input.data.message ? `: ${input.data.message}` : ""),
35+
`Configuration is invalid${input.data.path && input.data.path !== "config" ? ` at ${input.data.path}` : ""}` +
36+
(input.data.message ? `: ${input.data.message}` : ""),
3637
...(input.data.issues?.map((issue) => "↳ " + issue.message + " " + issue.path.join(".")) ?? []),
3738
].join("\n")
3839

packages/opencode/src/config/config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,17 @@ export namespace Config {
141141

142142
if (!result.keybinds) result.keybinds = Info.shape.keybinds.parse({})
143143

144+
// Only validate if user has configured agents - if none configured, built-in agents will be used
145+
if (Object.keys(result.agent).length > 0) {
146+
const primaryAgents = Object.values(result.agent).filter((a) => a.mode !== "subagent" && !a.hidden && !a.disable)
147+
if (primaryAgents.length === 0) {
148+
throw new InvalidError({
149+
path: "config",
150+
message: "No primary agents are available. Please configure at least one agent with mode 'primary' or 'all'.",
151+
})
152+
}
153+
}
154+
144155
return {
145156
config: result,
146157
directories,

0 commit comments

Comments
 (0)