refactor: kilo compat for v1.4.4

This commit is contained in:
Johnny Amancio
2026-04-15 11:30:02 +02:00
parent bddf830083
commit beb9b3b076
367 changed files with 1431 additions and 1372 deletions
@@ -1,6 +1,6 @@
import { test, expect, describe } from "bun:test"
import { resolvePluginProviders } from "../../src/cli/cmd/providers"
import type { Hooks } from "@opencode-ai/plugin"
import type { Hooks } from "@kilocode/plugin"
function hookWithAuth(provider: string): Hooks {
return {
@@ -30,7 +30,7 @@ test("adds tui plugin at runtime from spec", async () => {
},
})
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
process.env.KILO_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [],
plugin_origins: undefined,
@@ -56,7 +56,7 @@ test("adds tui plugin at runtime from spec", async () => {
cwd.mockRestore()
get.mockRestore()
wait.mockRestore()
delete process.env.OPENCODE_PLUGIN_META_FILE
delete process.env.KILO_PLUGIN_META_FILE
}
})
@@ -71,7 +71,7 @@ test("retries runtime add for file plugins after dependency wait", async () => {
},
})
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
process.env.KILO_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [],
plugin_origins: undefined,
@@ -102,6 +102,6 @@ test("retries runtime add for file plugins after dependency wait", async () => {
cwd.mockRestore()
get.mockRestore()
wait.mockRestore()
delete process.env.OPENCODE_PLUGIN_META_FILE
delete process.env.KILO_PLUGIN_META_FILE
}
})
@@ -49,7 +49,7 @@ test("installs plugin without loading it", async () => {
},
})
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
process.env.KILO_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const cfg: Awaited<ReturnType<typeof TuiConfig.get>> = {
plugin: [],
plugin_origins: undefined,
@@ -84,6 +84,6 @@ test("installs plugin without loading it", async () => {
cwd.mockRestore()
get.mockRestore()
wait.mockRestore()
delete process.env.OPENCODE_PLUGIN_META_FILE
delete process.env.KILO_PLUGIN_META_FILE
}
})
@@ -43,7 +43,7 @@ test("loads npm tui plugin from package ./tui export", async () => {
},
})
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
process.env.KILO_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [[tmp.extra.spec, { marker: tmp.extra.marker }]],
plugin_origins: [
@@ -71,7 +71,7 @@ test("loads npm tui plugin from package ./tui export", async () => {
cwd.mockRestore()
get.mockRestore()
wait.mockRestore()
delete process.env.OPENCODE_PLUGIN_META_FILE
delete process.env.KILO_PLUGIN_META_FILE
}
})
@@ -105,7 +105,7 @@ test("does not use npm package exports dot for tui entry", async () => {
},
})
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
process.env.KILO_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [tmp.extra.spec],
plugin_origins: [
@@ -130,7 +130,7 @@ test("does not use npm package exports dot for tui entry", async () => {
cwd.mockRestore()
get.mockRestore()
wait.mockRestore()
delete process.env.OPENCODE_PLUGIN_META_FILE
delete process.env.KILO_PLUGIN_META_FILE
}
})
@@ -168,7 +168,7 @@ test("rejects npm tui export that resolves outside plugin directory", async () =
},
})
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
process.env.KILO_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [tmp.extra.spec],
plugin_origins: [
@@ -195,7 +195,7 @@ test("rejects npm tui export that resolves outside plugin directory", async () =
cwd.mockRestore()
get.mockRestore()
wait.mockRestore()
delete process.env.OPENCODE_PLUGIN_META_FILE
delete process.env.KILO_PLUGIN_META_FILE
}
})
@@ -231,7 +231,7 @@ test("rejects npm tui plugin that exports server and tui together", async () =>
},
})
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
process.env.KILO_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [tmp.extra.spec],
plugin_origins: [
@@ -256,7 +256,7 @@ test("rejects npm tui plugin that exports server and tui together", async () =>
cwd.mockRestore()
get.mockRestore()
wait.mockRestore()
delete process.env.OPENCODE_PLUGIN_META_FILE
delete process.env.KILO_PLUGIN_META_FILE
}
})
@@ -290,7 +290,7 @@ test("does not use npm package main for tui entry", async () => {
},
})
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
process.env.KILO_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [tmp.extra.spec],
plugin_origins: [
@@ -321,7 +321,7 @@ test("does not use npm package main for tui entry", async () => {
wait.mockRestore()
warn.mockRestore()
error.mockRestore()
delete process.env.OPENCODE_PLUGIN_META_FILE
delete process.env.KILO_PLUGIN_META_FILE
}
})
@@ -356,7 +356,7 @@ test("does not use directory package main for tui entry", async () => {
},
})
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
process.env.KILO_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [tmp.extra.spec],
plugin_origins: [
@@ -379,7 +379,7 @@ test("does not use directory package main for tui entry", async () => {
cwd.mockRestore()
get.mockRestore()
wait.mockRestore()
delete process.env.OPENCODE_PLUGIN_META_FILE
delete process.env.KILO_PLUGIN_META_FILE
}
})
@@ -404,7 +404,7 @@ test("uses directory index fallback for tui when package.json is missing", async
},
})
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
process.env.KILO_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [tmp.extra.spec],
plugin_origins: [
@@ -427,7 +427,7 @@ test("uses directory index fallback for tui when package.json is missing", async
cwd.mockRestore()
get.mockRestore()
wait.mockRestore()
delete process.env.OPENCODE_PLUGIN_META_FILE
delete process.env.KILO_PLUGIN_META_FILE
}
})
@@ -462,7 +462,7 @@ test("uses npm package name when tui plugin id is omitted", async () => {
},
})
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
process.env.KILO_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [[tmp.extra.spec, { marker: tmp.extra.marker }]],
plugin_origins: [
@@ -487,6 +487,6 @@ test("uses npm package name when tui plugin id is omitted", async () => {
cwd.mockRestore()
get.mockRestore()
wait.mockRestore()
delete process.env.OPENCODE_PLUGIN_META_FILE
delete process.env.KILO_PLUGIN_META_FILE
}
})
@@ -32,10 +32,10 @@ test("skips external tui plugins in pure mode", async () => {
},
})
const pure = process.env.OPENCODE_PURE
const meta = process.env.OPENCODE_PLUGIN_META_FILE
process.env.OPENCODE_PURE = "1"
process.env.OPENCODE_PLUGIN_META_FILE = tmp.extra.meta
const pure = process.env.KILO_PURE
const meta = process.env.KILO_PLUGIN_META_FILE
process.env.KILO_PURE = "1"
process.env.KILO_PLUGIN_META_FILE = tmp.extra.meta
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [[tmp.extra.spec, { marker: tmp.extra.marker }]],
@@ -59,14 +59,14 @@ test("skips external tui plugins in pure mode", async () => {
get.mockRestore()
wait.mockRestore()
if (pure === undefined) {
delete process.env.OPENCODE_PURE
delete process.env.KILO_PURE
} else {
process.env.OPENCODE_PURE = pure
process.env.KILO_PURE = pure
}
if (meta === undefined) {
delete process.env.OPENCODE_PLUGIN_META_FILE
delete process.env.KILO_PLUGIN_META_FILE
} else {
process.env.OPENCODE_PLUGIN_META_FILE = meta
process.env.KILO_PLUGIN_META_FILE = meta
}
}
})
@@ -458,7 +458,7 @@ test("continues loading when a plugin is missing config metadata", async () => {
},
})
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
process.env.KILO_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [
[tmp.extra.badSpec, { marker: path.join(tmp.path, "bad.txt") }],
@@ -494,7 +494,7 @@ test("continues loading when a plugin is missing config metadata", async () => {
cwd.mockRestore()
get.mockRestore()
wait.mockRestore()
delete process.env.OPENCODE_PLUGIN_META_FILE
delete process.env.KILO_PLUGIN_META_FILE
}
})
@@ -551,7 +551,7 @@ export default {
},
})
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
process.env.KILO_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const cwd = spyOn(process, "cwd").mockImplementation(() => tmp.path)
try {
@@ -561,7 +561,7 @@ export default {
} finally {
await TuiPluginRuntime.dispose()
cwd.mockRestore()
delete process.env.OPENCODE_PLUGIN_META_FILE
delete process.env.KILO_PLUGIN_META_FILE
if (backupJson === undefined) {
await fs.rm(globalJson, { force: true }).catch(() => {})
@@ -695,7 +695,7 @@ test("updates installed theme when plugin metadata changes", async () => {
},
})
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
process.env.KILO_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const cwd = spyOn(process, "cwd").mockImplementation(() => tmp.path)
const wait = spyOn(TuiConfig, "waitForDependencies").mockResolvedValue()
@@ -735,13 +735,13 @@ test("updates installed theme when plugin metadata changes", async () => {
expect(text).toContain("#222222")
expect(text).not.toContain("#111111")
const list = await Filesystem.readJson<Record<string, { themes?: Record<string, { dest: string }> }>>(
process.env.OPENCODE_PLUGIN_META_FILE!,
process.env.KILO_PLUGIN_META_FILE!,
)
expect(list["demo.theme-update"]?.themes?.[tmp.extra.themeName]?.dest).toBe(tmp.extra.dest)
} finally {
await TuiPluginRuntime.dispose()
cwd.mockRestore()
wait.mockRestore()
delete process.env.OPENCODE_PLUGIN_META_FILE
delete process.env.KILO_PLUGIN_META_FILE
}
})
@@ -38,7 +38,7 @@ test("toggles plugin runtime state by exported id", async () => {
},
})
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
process.env.KILO_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [[tmp.extra.spec, { marker: tmp.extra.marker }]],
plugin_enabled: {
@@ -87,7 +87,7 @@ test("toggles plugin runtime state by exported id", async () => {
cwd.mockRestore()
get.mockRestore()
wait.mockRestore()
delete process.env.OPENCODE_PLUGIN_META_FILE
delete process.env.KILO_PLUGIN_META_FILE
}
})
@@ -116,7 +116,7 @@ test("kv plugin_enabled overrides tui config on startup", async () => {
},
})
process.env.OPENCODE_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
process.env.KILO_PLUGIN_META_FILE = path.join(tmp.path, "plugin-meta.json")
const get = spyOn(TuiConfig, "get").mockResolvedValue({
plugin: [[tmp.extra.spec, { marker: tmp.extra.marker }]],
plugin_enabled: {
@@ -154,6 +154,6 @@ test("kv plugin_enabled overrides tui config on startup", async () => {
cwd.mockRestore()
get.mockRestore()
wait.mockRestore()
delete process.env.OPENCODE_PLUGIN_META_FILE
delete process.env.KILO_PLUGIN_META_FILE
}
})
@@ -92,7 +92,7 @@ function createFetch(log: Hit[]) {
async (input: RequestInfo | URL, init?: RequestInit) => {
const req = new Request(input, init)
const url = new URL(req.url)
const workspace = url.searchParams.get("workspace") ?? req.headers.get("x-opencode-workspace") ?? undefined
const workspace = url.searchParams.get("workspace") ?? req.headers.get("x-kilo-workspace") ?? undefined
log.push({
path: url.pathname,
workspace,
@@ -5,7 +5,7 @@ import {
formatPart,
formatTranscript,
} from "../../../src/cli/cmd/tui/util/transcript"
import type { AssistantMessage, Part, Provider, UserMessage } from "@opencode-ai/sdk/v2"
import type { AssistantMessage, Part, Provider, UserMessage } from "@kilocode/sdk/v2"
const providers: Provider[] = [
{
@@ -1,7 +1,7 @@
/** @jsxImportSource @opentui/solid */
import { describe, expect, test } from "bun:test"
import { testRender } from "@opentui/solid"
import type { Event, GlobalEvent } from "@opencode-ai/sdk/v2"
import type { Event, GlobalEvent } from "@kilocode/sdk/v2"
import { onMount } from "solid-js"
import { ProjectProvider, useProject } from "../../../src/cli/cmd/tui/context/project"
import { SDKProvider } from "../../../src/cli/cmd/tui/context/sdk"