diff --git a/packages/core/src/config/plugin/agent.ts b/packages/core/src/config/plugin/agent.ts index d0fb754993a..b20be675565 100644 --- a/packages/core/src/config/plugin/agent.ts +++ b/packages/core/src/config/plugin/agent.ts @@ -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)) diff --git a/packages/core/test/config/agent.test.ts b/packages/core/test/config/agent.test.ts index 6bc844eb82a..a4938fd9dc8 100644 --- a/packages/core/test/config/agent.test.ts +++ b/packages/core/test/config/agent.test.ts @@ -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 diff --git a/services/site/src/docs/content/migrate-v1.mdx b/services/site/src/docs/content/migrate-v1.mdx index e7ce4ea00ed..cc1291bd21a 100644 --- a/services/site/src/docs/content/migrate-v1.mdx +++ b/services/site/src/docs/content/migrate-v1.mdx @@ -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