fix(converters): preserve Codex agent sidecar scripts (#563)
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { promises as fs } from "fs"
|
||||
import os from "os"
|
||||
import path from "path"
|
||||
import { convertClaudeToCodex } from "../src/converters/claude-to-codex"
|
||||
import { parseFrontmatter } from "../src/utils/frontmatter"
|
||||
import type { ClaudePlugin } from "../src/types/claude"
|
||||
@@ -344,6 +347,46 @@ Don't confuse with file paths like /tmp/output.md or /dev/null.`,
|
||||
expect(parsed.body).toContain("/dev/null")
|
||||
})
|
||||
|
||||
test("preserves agent script paths and tracks referenced sidecar directories", async () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "codex-agent-sidecar-"))
|
||||
const agentDir = path.join(tempRoot, "agents", "research")
|
||||
const scriptDir = path.join(agentDir, "session-history-scripts")
|
||||
await fs.mkdir(scriptDir, { recursive: true })
|
||||
|
||||
const plugin: ClaudePlugin = {
|
||||
...fixturePlugin,
|
||||
commands: [],
|
||||
skills: [],
|
||||
agents: [
|
||||
{
|
||||
name: "session-historian",
|
||||
description: "Session history research",
|
||||
body: [
|
||||
"Locate the `session-history-scripts/` directory.",
|
||||
"Run `bash <script-dir>/discover-sessions.sh repo 7`.",
|
||||
].join("\n"),
|
||||
sourcePath: path.join(agentDir, "session-historian.md"),
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const bundle = convertClaudeToCodex(plugin, {
|
||||
agentMode: "subagent",
|
||||
inferTemperature: false,
|
||||
permissions: "none",
|
||||
})
|
||||
|
||||
const agentSkill = bundle.generatedSkills.find((s) => s.name === "session-historian")
|
||||
expect(agentSkill).toBeDefined()
|
||||
expect(agentSkill!.sidecarDirs).toEqual([
|
||||
{ sourceDir: scriptDir, targetName: "session-history-scripts" },
|
||||
])
|
||||
|
||||
const parsed = parseFrontmatter(agentSkill!.content)
|
||||
expect(parsed.body).toContain("<script-dir>/discover-sessions.sh")
|
||||
expect(parsed.body).not.toContain("<script-dir>/prompts:discover-sessions.sh")
|
||||
})
|
||||
|
||||
test("transforms canonical workflow slash commands to Codex prompt references", () => {
|
||||
const plugin: ClaudePlugin = {
|
||||
...fixturePlugin,
|
||||
|
||||
@@ -76,6 +76,38 @@ describe("writeCodexBundle", () => {
|
||||
expect(await exists(path.join(codexRoot, "skills", "skill-one", "SKILL.md"))).toBe(true)
|
||||
})
|
||||
|
||||
test("copies generated skill sidecar directories", async () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "codex-sidecar-"))
|
||||
const sidecarDir = path.join(tempRoot, "source", "session-history-scripts")
|
||||
await fs.mkdir(sidecarDir, { recursive: true })
|
||||
await fs.writeFile(path.join(sidecarDir, "discover-sessions.sh"), "#!/usr/bin/env bash\n")
|
||||
|
||||
const bundle: CodexBundle = {
|
||||
prompts: [],
|
||||
skillDirs: [],
|
||||
generatedSkills: [
|
||||
{
|
||||
name: "session-historian",
|
||||
content: "Skill content",
|
||||
sidecarDirs: [{ sourceDir: sidecarDir, targetName: "session-history-scripts" }],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
await writeCodexBundle(tempRoot, bundle)
|
||||
|
||||
expect(await exists(
|
||||
path.join(
|
||||
tempRoot,
|
||||
".codex",
|
||||
"skills",
|
||||
"session-historian",
|
||||
"session-history-scripts",
|
||||
"discover-sessions.sh",
|
||||
),
|
||||
)).toBe(true)
|
||||
})
|
||||
|
||||
test("preserves existing user config when writing MCP servers", async () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "codex-backup-"))
|
||||
const codexRoot = path.join(tempRoot, ".codex")
|
||||
|
||||
Reference in New Issue
Block a user