fix(core): keep agents whose description starts with a bracketed tag (#62250)

This commit is contained in:
DS
2026-11-06 17:56:22 -05:00
committed by GitHub
Unverified
parent 0ce87485e8
commit 64f2403ffa
2 changed files with 10 additions and 3 deletions
+4 -3
View File
@@ -21,8 +21,9 @@ export function parseOption(content: string) {
}
}
// Other coding agents accept unquoted colons in frontmatter values. Retry
// those values as YAML block scalars so existing config files keep working.
// Other coding agents accept unquoted colons and leading tags like `[Tag] text`
// in frontmatter values. Retry those values as YAML block scalars so existing
// config files keep working.
export function sanitize(content: string) {
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/)
if (!match) return content
@@ -33,7 +34,7 @@ export function sanitize(content: string) {
if (!entry) return [line]
const value = entry[2].trim()
if (value === "" || value === ">" || value === "|" || value.startsWith('"') || value.startsWith("'")) return [line]
if (!value.includes(":")) return [line]
if (!value.includes(":") && !/^[[{].*[\]}]\s*\S/.test(value)) return [line]
return [`${entry[1]}: |-`, ` ${value}`]
})
return content.replace(frontmatter, () => result.join("\n"))
@@ -13,6 +13,12 @@ describe("ConfigMarkdown.parse", () => {
expect(parsed.content.trim()).toBe("body")
})
test("recovers a frontmatter value that starts with a bracketed tag", () => {
const parsed = ConfigMarkdown.parse("---\ndescription: [Team] Does a thing\ntools: [read, edit]\n---\nbody")
expect(parsed.data.description).toBe("[Team] Does a thing")
expect(parsed.data.tools).toEqual(["read", "edit"])
})
test("recovers the same content again after a previous failed parse", () => {
// gray-matter caches by content before parsing; a poisoned entry used to
// make every later parse of the same text return silently without data.