feat(core): support name frontmatter in markdown agent files (#67051)

Co-authored-by: Tarquinen <78942835+Tarquinen@users.noreply.github.com>
Co-authored-by: Dan Smolsky <dannysmo@gmail.com>
This commit is contained in:
opencode-agent[bot] 2026-11-29 02:39:46 +00:00 • committed by GitHub
parent 107fa22ac6
commit c1d2d2eb62
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 9 deletions

View file

@ -29,7 +29,7 @@ const decodeAgent = SchemaParser.decodeUnknownResult(ConfigAgent.Info)
const decodeLegacyAgent = SchemaParser.decodeUnknownResult(ConfigAgentV1.Info)
const formatIssue = SchemaIssue.makeFormatterDefault()
type PathAction = FileAccess.ExternalDirectoryAuthorization["action"] | typeof ReadTool.name | typeof EditTool.name
const agentKeys = new Set(["variant", ...Object.keys(ConfigAgent.Info.fields)])
const agentKeys = new Set(["name", "variant", ...Object.keys(ConfigAgent.Info.fields)])
// Fields only V2 understands. A file that uses any of them is read as V2, whatever else it contains.
const nativeKeys = ["permissions", "request", "system", "disabled"]
@ -153,11 +153,14 @@ const decode = Effect.fnUntraced(function* (
yield* Effect.logWarning("agent file skipped", { filepath: file.filepath, reason: "markdown" })
return
}
const name = path
.relative(file.directory, file.filepath)
.replaceAll("\\", "/")
.replace(/^(agent|agents|mode|modes)\//, "")
.replace(/\.md$/, "")
const name =
typeof markdown.data.name === "string"
? markdown.data.name
: path
.relative(file.directory, file.filepath)
.replaceAll("\\", "/")
.replace(/^(agent|agents|mode|modes)\//, "")
.replace(/\.md$/, "")
const body = markdown.content.trim()
const keys = Object.keys(markdown.data)
const unsupported = keys.filter((key) => !agentKeys.has(key))

View file

@ -542,7 +542,7 @@ Use native v2 fields.`,
yield* Effect.promise(async () => {
await fs.mkdir(path.join(tmp.path, "agents"), { recursive: true })
await fs.writeFile(
path.join(tmp.path, "agents", "named.md"),
path.join(tmp.path, "agents", "reviewer.md"),
`---
name: named
description: Named reviewer

View file

@ -506,8 +506,8 @@ When converting the frontmatter to native V2 fields:
- Set sampling and provider options on a model variant, as shown [above](#agents-and-modes).
V1 agent frontmatter is deprecated but still translated automatically. Each file is read as one format. A file that
uses any of `permissions`, `request`, `system`, or `disabled` is read as V2, and V1 fields in it, such as `name`,
`tools`, `permission`, or `temperature`, are ignored with a warning in the log. Other files that use V1 fields are read
uses any of `permissions`, `request`, `system`, or `disabled` is read as V2, and V1 fields in it, such as `tools`,
`permission`, or `temperature`, are ignored with a warning in the log. Other files that use V1 fields are read
as V1. Convert a file's frontmatter all at once rather than mixing the two formats. See [Agents](/agents).
### Command files