feat: add OpenCode/Codex outputs and update changelog (#104)
* Add OpenCode converter coverage and specs * Add Codex target support and spec docs * Generate Codex command skills and refresh spec docs * Add global Codex install path * fix: harden plugin path loading and codex descriptions * feat: ensure codex agents block on convert/install * docs: clarify target branch usage for review * chore: prep npm package metadata and release notes * docs: mention opencode and codex in changelog * docs: update CLI usage and remove stale todos * feat: install from GitHub with global outputs
This commit is contained in:
76
tests/codex-writer.test.ts
Normal file
76
tests/codex-writer.test.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { promises as fs } from "fs"
|
||||
import path from "path"
|
||||
import os from "os"
|
||||
import { writeCodexBundle } from "../src/targets/codex"
|
||||
import type { CodexBundle } from "../src/types/codex"
|
||||
|
||||
async function exists(filePath: string): Promise<boolean> {
|
||||
try {
|
||||
await fs.access(filePath)
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
describe("writeCodexBundle", () => {
|
||||
test("writes prompts, skills, and config", async () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "codex-test-"))
|
||||
const bundle: CodexBundle = {
|
||||
prompts: [{ name: "command-one", content: "Prompt content" }],
|
||||
skillDirs: [
|
||||
{
|
||||
name: "skill-one",
|
||||
sourceDir: path.join(import.meta.dir, "fixtures", "sample-plugin", "skills", "skill-one"),
|
||||
},
|
||||
],
|
||||
generatedSkills: [{ name: "agent-skill", content: "Skill content" }],
|
||||
mcpServers: {
|
||||
local: { command: "echo", args: ["hello"], env: { KEY: "VALUE" } },
|
||||
remote: {
|
||||
url: "https://example.com/mcp",
|
||||
headers: { Authorization: "Bearer token" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
await writeCodexBundle(tempRoot, bundle)
|
||||
|
||||
expect(await exists(path.join(tempRoot, ".codex", "prompts", "command-one.md"))).toBe(true)
|
||||
expect(await exists(path.join(tempRoot, ".codex", "skills", "skill-one", "SKILL.md"))).toBe(true)
|
||||
expect(await exists(path.join(tempRoot, ".codex", "skills", "agent-skill", "SKILL.md"))).toBe(true)
|
||||
const configPath = path.join(tempRoot, ".codex", "config.toml")
|
||||
expect(await exists(configPath)).toBe(true)
|
||||
|
||||
const config = await fs.readFile(configPath, "utf8")
|
||||
expect(config).toContain("[mcp_servers.local]")
|
||||
expect(config).toContain("command = \"echo\"")
|
||||
expect(config).toContain("args = [\"hello\"]")
|
||||
expect(config).toContain("[mcp_servers.local.env]")
|
||||
expect(config).toContain("KEY = \"VALUE\"")
|
||||
expect(config).toContain("[mcp_servers.remote]")
|
||||
expect(config).toContain("url = \"https://example.com/mcp\"")
|
||||
expect(config).toContain("http_headers")
|
||||
})
|
||||
|
||||
test("writes directly into a .codex output root", async () => {
|
||||
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "codex-home-"))
|
||||
const codexRoot = path.join(tempRoot, ".codex")
|
||||
const bundle: CodexBundle = {
|
||||
prompts: [{ name: "command-one", content: "Prompt content" }],
|
||||
skillDirs: [
|
||||
{
|
||||
name: "skill-one",
|
||||
sourceDir: path.join(import.meta.dir, "fixtures", "sample-plugin", "skills", "skill-one"),
|
||||
},
|
||||
],
|
||||
generatedSkills: [],
|
||||
}
|
||||
|
||||
await writeCodexBundle(codexRoot, bundle)
|
||||
|
||||
expect(await exists(path.join(codexRoot, "prompts", "command-one.md"))).toBe(true)
|
||||
expect(await exists(path.join(codexRoot, "skills", "skill-one", "SKILL.md"))).toBe(true)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user