Skip to content

Commit 4789bfd

Browse files
committed
fix(config): preserve description field from markdown agent frontmatter
When loading agents from markdown files (.opencode/agents/*.md), the description field from YAML frontmatter could be lost during the schema decode process. The normalize() function relied on spreading all decoded properties via ...agent, but when the Schema.decodeTo wrapper interferes with the decode, description may not be included. Two changes: 1. normalize() now explicitly carries description through the return value 2. load() now falls back to the raw frontmatter description if the schema decoded result lacks it Fixes anomalyco#27831
1 parent c0a8b50 commit 4789bfd

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎packages/opencode/src/config/agent.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ const normalize = (agent: Schema.Schema.Type<typeof AgentSchema>): Schema.Schema
9393
globalThis.Object.assign(permission, agent.permission)
9494

9595
const steps = agent.steps ?? agent.maxSteps
96-
return { ...agent, options, permission, ...(steps !== undefined ? { steps } : {}) }
96+
const description = "description" in agent ? agent.description : undefined
97+
return { ...agent, options, permission, description, ...(steps !== undefined ? { steps } : {}) }
9798
}
9899

99100
export const Info = AgentSchema.pipe(
@@ -131,7 +132,11 @@ export async function load(dir: string) {
131132
...md.data,
132133
prompt: md.content.trim(),
133134
}
134-
result[config.name] = ConfigParse.schema(Info, config, item)
135+
const parsed = ConfigParse.schema(Info, config, item)
136+
if ("description" in config && !parsed.description) {
137+
parsed.description = config.description
138+
}
139+
result[config.name] = parsed
135140
}
136141
return result
137142
}

0 commit comments

Comments
 (0)