11import type { Plugin } from "@opencode-ai/plugin"
2- import { createBuiltinAgents , type AgentName , type AgentOverrides } from "./agents"
2+ import { createBuiltinAgents } from "./agents"
33import { createTodoContinuationEnforcer , createContextWindowMonitorHook , createSessionRecoveryHook } from "./hooks"
44import { updateTerminalTitle } from "./features/terminal"
55import { builtinTools } from "./tools"
6- import { createBuiltinMcps , type McpName } from "./mcp"
6+ import { createBuiltinMcps } from "./mcp"
7+ import { OhMyOpenCodeConfigSchema , type OhMyOpenCodeConfig } from "./config"
78import * as fs from "fs"
89import * as path from "path"
910
10- interface OhMyOpenCodeConfig {
11- disabled_mcps ?: McpName [ ]
12- disabled_agents ?: AgentName [ ]
13- agents ?: AgentOverrides
14- }
15-
1611function loadPluginConfig ( directory : string ) : OhMyOpenCodeConfig {
1712 const configPaths = [
1813 path . join ( directory , "oh-my-opencode.json" ) ,
@@ -23,7 +18,18 @@ function loadPluginConfig(directory: string): OhMyOpenCodeConfig {
2318 try {
2419 if ( fs . existsSync ( configPath ) ) {
2520 const content = fs . readFileSync ( configPath , "utf-8" )
26- return JSON . parse ( content ) as OhMyOpenCodeConfig
21+ const rawConfig = JSON . parse ( content )
22+ const result = OhMyOpenCodeConfigSchema . safeParse ( rawConfig )
23+
24+ if ( ! result . success ) {
25+ console . error ( `[oh-my-opencode] Config validation error in ${ configPath } :` )
26+ for ( const issue of result . error . issues ) {
27+ console . error ( ` - ${ issue . path . join ( "." ) } : ${ issue . message } ` )
28+ }
29+ return { }
30+ }
31+
32+ return result . data
2733 }
2834 } catch {
2935 // Ignore parse errors, use defaults
@@ -184,5 +190,11 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
184190
185191export default OhMyOpenCodePlugin
186192
187- export type { AgentName , AgentOverrideConfig , AgentOverrides } from "./agents"
188- export type { McpName } from "./mcp"
193+ export { OhMyOpenCodeConfigSchema } from "./config"
194+ export type {
195+ OhMyOpenCodeConfig ,
196+ AgentName ,
197+ AgentOverrideConfig ,
198+ AgentOverrides ,
199+ McpName ,
200+ } from "./config"
0 commit comments