* 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
63 lines
2.3 KiB
TypeScript
63 lines
2.3 KiB
TypeScript
import { describe, expect, test } from "bun:test"
|
|
import { promises as fs } from "fs"
|
|
import path from "path"
|
|
import os from "os"
|
|
import { writeOpenCodeBundle } from "../src/targets/opencode"
|
|
import type { OpenCodeBundle } from "../src/types/opencode"
|
|
|
|
async function exists(filePath: string): Promise<boolean> {
|
|
try {
|
|
await fs.access(filePath)
|
|
return true
|
|
} catch {
|
|
return false
|
|
}
|
|
}
|
|
|
|
describe("writeOpenCodeBundle", () => {
|
|
test("writes config, agents, plugins, and skills", async () => {
|
|
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "opencode-test-"))
|
|
const bundle: OpenCodeBundle = {
|
|
config: { $schema: "https://opencode.ai/config.json" },
|
|
agents: [{ name: "agent-one", content: "Agent content" }],
|
|
plugins: [{ name: "hook.ts", content: "export {}" }],
|
|
skillDirs: [
|
|
{
|
|
name: "skill-one",
|
|
sourceDir: path.join(import.meta.dir, "fixtures", "sample-plugin", "skills", "skill-one"),
|
|
},
|
|
],
|
|
}
|
|
|
|
await writeOpenCodeBundle(tempRoot, bundle)
|
|
|
|
expect(await exists(path.join(tempRoot, "opencode.json"))).toBe(true)
|
|
expect(await exists(path.join(tempRoot, ".opencode", "agents", "agent-one.md"))).toBe(true)
|
|
expect(await exists(path.join(tempRoot, ".opencode", "plugins", "hook.ts"))).toBe(true)
|
|
expect(await exists(path.join(tempRoot, ".opencode", "skills", "skill-one", "SKILL.md"))).toBe(true)
|
|
})
|
|
|
|
test("writes directly into a .opencode output root", async () => {
|
|
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "opencode-root-"))
|
|
const outputRoot = path.join(tempRoot, ".opencode")
|
|
const bundle: OpenCodeBundle = {
|
|
config: { $schema: "https://opencode.ai/config.json" },
|
|
agents: [{ name: "agent-one", content: "Agent content" }],
|
|
plugins: [],
|
|
skillDirs: [
|
|
{
|
|
name: "skill-one",
|
|
sourceDir: path.join(import.meta.dir, "fixtures", "sample-plugin", "skills", "skill-one"),
|
|
},
|
|
],
|
|
}
|
|
|
|
await writeOpenCodeBundle(outputRoot, bundle)
|
|
|
|
expect(await exists(path.join(outputRoot, "opencode.json"))).toBe(true)
|
|
expect(await exists(path.join(outputRoot, "agents", "agent-one.md"))).toBe(true)
|
|
expect(await exists(path.join(outputRoot, "skills", "skill-one", "SKILL.md"))).toBe(true)
|
|
expect(await exists(path.join(outputRoot, ".opencode"))).toBe(false)
|
|
})
|
|
})
|