diff --git a/packages/opencode/src/config/markdown.ts b/packages/opencode/src/config/markdown.ts index 3c9709b5b3b..264c6a6c537 100644 --- a/packages/opencode/src/config/markdown.ts +++ b/packages/opencode/src/config/markdown.ts @@ -6,6 +6,8 @@ import { Filesystem } from "../util/filesystem" export namespace ConfigMarkdown { export const FILE_REGEX = /(? { @@ -226,3 +229,47 @@ describe("ConfigMarkdown: frontmatter has weird model id", async () => { expect(result.content.trim()).toBe("Strictly follow da rules") }) }) + +describe("ConfigMarkdown: frontmatter parsing w/ hex colors", () => { + let dir: string + + beforeAll(async () => { + dir = await mkdtemp(path.join(tmpdir(), "opencode-markdown-")) + + await writeFile( + path.join(dir, "quoted-hex.md"), + `--- +name: Quoted Hex +color: "#008080" +--- + +Content +`, + ) + + await writeFile( + path.join(dir, "unquoted-hex.md"), + `--- +name: Unquoted Hex +color: #008080 +--- + +Content +`, + ) + }) + + afterAll(async () => { + await rm(dir, { recursive: true, force: true }) + }) + + test("should preserve quoted hex colors", async () => { + const result = await ConfigMarkdown.parse(path.join(dir, "quoted-hex.md")) + expect(result.data.color).toBe("#008080") + }) + + test("should recover unquoted hex colors that YAML treats as comments", async () => { + const result = await ConfigMarkdown.parse(path.join(dir, "unquoted-hex.md")) + expect(result.data.color).toBe("#008080") + }) +})