Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/opencode-plugin/tests/mcp-config.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from "node:test"
import assert from "node:assert/strict"
import { readFile } from "node:fs/promises"
import { fileURLToPath } from "node:url"
import { dirname, join } from "node:path"
import { dirname, join, resolve } from "node:path"
import { createOpenVikingMcpConfig, createOpenVikingV2McpConfig, injectOpenVikingMcpConfig, injectOpenVikingSkillPaths } from "../lib/mcp-config.mjs"

const testDir = dirname(fileURLToPath(import.meta.url))
Expand All @@ -13,7 +13,7 @@ test("injectOpenVikingMcpConfig registers a local stdio MCP server", () => {
assert.equal(injectOpenVikingMcpConfig(config, "/tmp/openviking-plugin"), true)
assert.deepEqual(config.mcp.openviking, {
type: "local",
command: ["node", "/tmp/openviking-plugin/servers/mcp-proxy.mjs"],
command: ["node", resolve("/tmp/openviking-plugin", "servers", "mcp-proxy.mjs")],
enabled: true,
timeout: 15000,
})
Expand All @@ -40,7 +40,7 @@ test("injectOpenVikingSkillPaths appends the bundled skills directory once", ()

assert.equal(injectOpenVikingSkillPaths(config, "/tmp/openviking-plugin"), true)
injectOpenVikingSkillPaths(config, "/tmp/openviking-plugin")
assert.deepEqual(config.skills.paths, [".opencode/skills", "/tmp/openviking-plugin/skills"])
assert.deepEqual(config.skills.paths, [".opencode/skills", resolve("/tmp/openviking-plugin", "skills")])
})

test("OpenCode plugin adds its skills only after registering the MCP server", async () => {
Expand Down Expand Up @@ -72,15 +72,15 @@ test("OpenCode MCP config points to the proxy entrypoint", () => {

assert.equal(entry.type, "local")
assert.equal(entry.command[0], "node")
assert.match(entry.command[1], /servers\/mcp-proxy\.mjs$/)
assert.match(entry.command[1], /servers[\\/]mcp-proxy\.mjs$/)
})

test("OpenCode v2 MCP config uses the local server schema", () => {
const entry = createOpenVikingV2McpConfig("/tmp/ov")

assert.equal(entry.type, "local")
assert.equal(entry.command[0], "node")
assert.match(entry.command[1], /servers\/mcp-proxy\.mjs$/)
assert.match(entry.command[1], /servers[\\/]mcp-proxy\.mjs$/)
assert.equal(entry.enabled, undefined)
assert.equal(entry.codemode, false)
assert.deepEqual(entry.timeout, { startup: 15000, catalog: 15000, execution: 15000 })
Expand Down
3 changes: 2 additions & 1 deletion examples/opencode-plugin/tests/v2-plugin.test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import test from "node:test"
import assert from "node:assert/strict"
import { resolve } from "node:path"
import { captureV2Context, injectV2Context, prepareV2Prompt, startV2Plugin } from "../lib/v2-plugin.mjs"
import { createVikingUriNotice } from "../lib/viking-uri-guard.mjs"

Expand Down Expand Up @@ -62,7 +63,7 @@ test("startV2Plugin registers direct MCP tools and all v2 hooks", async () => {
const { ctx, hooks, registered, skillSources } = contextFixture()
const cleanup = await startV2Plugin(ctx, runtime, { pluginRoot: "/tmp/ov" })

assert.deepEqual(skillSources, [{ type: "directory", path: "/tmp/ov/skills" }])
assert.deepEqual(skillSources, [{ type: "directory", path: resolve("/tmp/ov", "skills") }])
assert.equal(registered[0][0], "openviking")
assert.equal(registered[0][1].type, "local")
assert.equal(registered[0][1].codemode, false)
Expand Down