Skip to content

Commit 37b6ad5

Browse files
committed
fix(ClaudeAdapter): strip surrounding quotes from scalar frontmatter values
ClaudeAdapter.parseFrontmatter stripped quotes only from array items, never from scalar values, so a quoted scalar like `name: "SubAgent"` parsed to the literal `"SubAgent"` (embedded quotes). The adapter's own generateClaudeAgentMarkdown emits every scalar quoted, so a subagent fromOAC -> toOAC round-trip mangled name/description/model. The sibling CursorAdapter.parseFrontmatter already does value.replace(/^["']|["']$/g, ""), proving the intended behavior. Apply the same scalar quote-strip. Add a regression test.
1 parent 37ca233 commit 37b6ad5

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

packages/compatibility-layer/src/adapters/ClaudeAdapter.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@ export class ClaudeAdapter extends BaseAdapter {
276276
.slice(1, -1)
277277
.split(",")
278278
.map((v) => v.trim().replace(/"/g, ""));
279+
} else if (typeof value === "string") {
280+
// Strip surrounding quotes from scalar values (matches
281+
// CursorAdapter.parseFrontmatter, and undoes the quoting that
282+
// generateClaudeAgentMarkdown adds, e.g. name: "...").
283+
value = value.replace(/^["']|["']$/g, "");
279284
}
280285

281286
frontmatter[key] = value;

packages/compatibility-layer/tests/unit/adapters/ClaudeAdapter.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,24 @@ This is the system prompt for the agent.`;
235235
expect(result.systemPrompt).toBe("This is the system prompt for the agent.");
236236
});
237237

238+
it("strips surrounding quotes from scalar frontmatter values", async () => {
239+
// generateClaudeAgentMarkdown emits quoted scalars (name: "..."), so a
240+
// fromOAC -> toOAC round-trip must not leave the embedded quotes.
241+
const source = `---
242+
name: "SubAgent"
243+
description: "A subagent"
244+
model: "claude-opus-4"
245+
---
246+
247+
Prompt body`;
248+
249+
const result = await adapter.toOAC(source);
250+
251+
expect(result.frontmatter.name).toBe("SubAgent");
252+
expect(result.frontmatter.description).toBe("A subagent");
253+
expect(result.frontmatter.model).toBe("claude-opus-4");
254+
});
255+
238256
it("parses agent.md with model in frontmatter", async () => {
239257
const source = `---
240258
name: Agent

0 commit comments

Comments
 (0)