fix: harden codex copied skill rewriting (#285)

This commit is contained in:
Kieran Klaassen
2026-03-16 21:25:59 -07:00
committed by GitHub
parent 82c1fe86df
commit 6f561f94b4
6 changed files with 111 additions and 3 deletions

View File

@@ -61,4 +61,22 @@ describe("loadClaudeHome", () => {
expect(config.skills[0]?.description).toBe("Reviewer skill")
expect(config.skills[0]?.argumentHint).toBe("[topic]")
})
test("keeps personal skills when frontmatter is malformed", async () => {
const tempHome = await fs.mkdtemp(path.join(os.tmpdir(), "claude-home-skill-yaml-"))
const skillDir = path.join(tempHome, "skills", "reviewer")
await fs.mkdir(skillDir, { recursive: true })
await fs.writeFile(
path.join(skillDir, "SKILL.md"),
"---\nname: ce:plan\nfoo: [unterminated\n---\nReview things.\n",
)
const config = await loadClaudeHome(tempHome)
expect(config.skills).toHaveLength(1)
expect(config.skills[0]?.name).toBe("reviewer")
expect(config.skills[0]?.description).toBeUndefined()
expect(config.skills[0]?.argumentHint).toBeUndefined()
})
})

View File

@@ -206,4 +206,57 @@ Also run bare agents:
expect(installedSkill).toContain("Use the $best-practices-researcher skill to: topic")
expect(installedSkill).not.toContain("Task best-practices-researcher")
})
test("preserves unknown slash text in copied SKILL.md files", async () => {
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "codex-skill-preserve-"))
const sourceSkillDir = path.join(tempRoot, "source-skill")
await fs.mkdir(sourceSkillDir, { recursive: true })
await fs.writeFile(
path.join(sourceSkillDir, "SKILL.md"),
`---
name: proof
description: Proof skill
---
Route examples:
- /users
- /settings
API examples:
- https://www.proofeditor.ai/api/agent/{slug}/state
- https://www.proofeditor.ai/share/markdown
Workflow handoff:
- /ce:plan
`,
)
const bundle: CodexBundle = {
prompts: [],
skillDirs: [{ name: "proof", sourceDir: sourceSkillDir }],
generatedSkills: [],
invocationTargets: {
promptTargets: {
"ce-plan": "ce-plan",
},
skillTargets: {},
},
}
await writeCodexBundle(tempRoot, bundle)
const installedSkill = await fs.readFile(
path.join(tempRoot, ".codex", "skills", "proof", "SKILL.md"),
"utf8",
)
expect(installedSkill).toContain("/users")
expect(installedSkill).toContain("/settings")
expect(installedSkill).toContain("https://www.proofeditor.ai/api/agent/{slug}/state")
expect(installedSkill).toContain("https://www.proofeditor.ai/share/markdown")
expect(installedSkill).toContain("/prompts:ce-plan")
expect(installedSkill).not.toContain("/prompts:users")
expect(installedSkill).not.toContain("/prompts:settings")
expect(installedSkill).not.toContain("https://prompts:www.proofeditor.ai")
})
})