summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2025-12-20 13:47:28 -0600
committerAiden Cline <[email protected]>2025-12-20 13:47:28 -0600
commit9caaae6a185957b4dc58d4eadf86d8af8a8fdbd5 (patch)
treeeae0269ffe4b8b6e8dd1e63cacccc1d17e1d2c81 /packages
parentad6a5e6157ea728d3d2cb29297d6bbb5f79dc6bc (diff)
downloadopencode-9caaae6a185957b4dc58d4eadf86d8af8a8fdbd5.tar.gz
opencode-9caaae6a185957b4dc58d4eadf86d8af8a8fdbd5.zip
tweak: better error message if no primary agents are enabled
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/src/cli/error.ts3
-rw-r--r--packages/opencode/src/config/config.ts11
2 files changed, 13 insertions, 1 deletions
diff --git a/packages/opencode/src/cli/error.ts b/packages/opencode/src/cli/error.ts
index 07a53d293..54ced0d7a 100644
--- a/packages/opencode/src/cli/error.ts
+++ b/packages/opencode/src/cli/error.ts
@@ -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")
diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts
index 031bdd31b..1158d67f4 100644
--- a/packages/opencode/src/config/config.ts
+++ b/packages/opencode/src/config/config.ts
@@ -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,