mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 03:24:54 +00:00
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:
parent
107fa22ac6
commit
c1d2d2eb62
3 changed files with 12 additions and 9 deletions
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue