fix: address code review findings for gemini target
- Extract named GeminiMcpServer type (eliminates NonNullable indexing) - Deep-merge mcpServers in settings.json (preserves existing entries) - Warn when existing settings.json cannot be parsed - Add test for uniqueName dedup (agent/skill name collision) - Add test for TOML triple-quote escaping Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -267,6 +267,25 @@ describe("convertClaudeToGemini", () => {
|
||||
expect(bundle.commands).toHaveLength(0)
|
||||
})
|
||||
|
||||
test("agent name colliding with skill name gets deduplicated", () => {
|
||||
const plugin: ClaudePlugin = {
|
||||
...fixturePlugin,
|
||||
skills: [{ name: "security-reviewer", description: "Existing skill", sourceDir: "/tmp/skill", skillPath: "/tmp/skill/SKILL.md" }],
|
||||
agents: [{ name: "Security Reviewer", description: "Agent version", body: "Body.", sourcePath: "/tmp/agents/sr.md" }],
|
||||
commands: [],
|
||||
}
|
||||
|
||||
const bundle = convertClaudeToGemini(plugin, {
|
||||
agentMode: "subagent",
|
||||
inferTemperature: false,
|
||||
permissions: "none",
|
||||
})
|
||||
|
||||
// Agent should be deduplicated since skill already has "security-reviewer"
|
||||
expect(bundle.generatedSkills[0].name).toBe("security-reviewer-2")
|
||||
expect(bundle.skillDirs[0].name).toBe("security-reviewer")
|
||||
})
|
||||
|
||||
test("hooks present emits console.warn", () => {
|
||||
const warnings: string[] = []
|
||||
const originalWarn = console.warn
|
||||
@@ -339,4 +358,16 @@ describe("toToml", () => {
|
||||
const result = toToml('Say "hello"', "Prompt")
|
||||
expect(result).toContain('description = "Say \\"hello\\""')
|
||||
})
|
||||
|
||||
test("escapes triple quotes in prompt", () => {
|
||||
const result = toToml("A command", 'Content with """ inside it')
|
||||
// Should not contain an unescaped """ that would close the TOML multi-line string prematurely
|
||||
// The prompt section should have the escaped version
|
||||
expect(result).toContain('description = "A command"')
|
||||
expect(result).toContain('prompt = """')
|
||||
// The inner """ should be escaped
|
||||
expect(result).not.toMatch(/""".*""".*"""/s) // Should not have 3 separate triple-quote sequences (open, content, close would make 3)
|
||||
// Verify it contains the escaped form
|
||||
expect(result).toContain('\\"\\"\\"')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -173,7 +173,9 @@ describe("writeGeminiBundle", () => {
|
||||
const content = JSON.parse(await fs.readFile(settingsPath, "utf8"))
|
||||
// Should preserve existing model key
|
||||
expect(content.model).toBe("gemini-2.5-pro")
|
||||
// mcpServers should be replaced (not merged) with new content
|
||||
// Should preserve existing MCP server
|
||||
expect(content.mcpServers.old.command).toBe("old-cmd")
|
||||
// Should add new MCP server
|
||||
expect(content.mcpServers.newServer.command).toBe("new-cmd")
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user