mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-21 05:52:35 +08:00
refactor: kilo compat for v1.4.9
This commit is contained in:
@@ -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 config: TuiConfig.Info = {
|
||||
plugin: [],
|
||||
plugin_origins: undefined,
|
||||
@@ -58,7 +58,7 @@ test("adds tui plugin at runtime from spec", async () => {
|
||||
await TuiPluginRuntime.dispose()
|
||||
cwd.mockRestore()
|
||||
wait.mockRestore()
|
||||
delete process.env.OPENCODE_PLUGIN_META_FILE
|
||||
delete process.env.KILO_PLUGIN_META_FILE
|
||||
}
|
||||
})
|
||||
|
||||
@@ -73,7 +73,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 config: TuiConfig.Info = {
|
||||
plugin: [],
|
||||
plugin_origins: undefined,
|
||||
@@ -106,6 +106,6 @@ test("retries runtime add for file plugins after dependency wait", async () => {
|
||||
await TuiPluginRuntime.dispose()
|
||||
cwd.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 config: TuiConfig.Info = {
|
||||
plugin: [],
|
||||
plugin_origins: undefined,
|
||||
@@ -82,6 +82,6 @@ test("installs plugin without loading it", async () => {
|
||||
await TuiPluginRuntime.dispose()
|
||||
cwd.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 config: TuiConfig.Info = {
|
||||
plugin: [[tmp.extra.spec, { marker: tmp.extra.marker }]],
|
||||
plugin_origins: [
|
||||
@@ -70,7 +70,7 @@ test("loads npm tui plugin from package ./tui export", async () => {
|
||||
install.mockRestore()
|
||||
cwd.mockRestore()
|
||||
wait.mockRestore()
|
||||
delete process.env.OPENCODE_PLUGIN_META_FILE
|
||||
delete process.env.KILO_PLUGIN_META_FILE
|
||||
}
|
||||
})
|
||||
|
||||
@@ -104,7 +104,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 config: TuiConfig.Info = {
|
||||
plugin: [tmp.extra.spec],
|
||||
plugin_origins: [
|
||||
@@ -128,7 +128,7 @@ test("does not use npm package exports dot for tui entry", async () => {
|
||||
install.mockRestore()
|
||||
cwd.mockRestore()
|
||||
wait.mockRestore()
|
||||
delete process.env.OPENCODE_PLUGIN_META_FILE
|
||||
delete process.env.KILO_PLUGIN_META_FILE
|
||||
}
|
||||
})
|
||||
|
||||
@@ -166,7 +166,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 config: TuiConfig.Info = {
|
||||
plugin: [tmp.extra.spec],
|
||||
plugin_origins: [
|
||||
@@ -192,7 +192,7 @@ test("rejects npm tui export that resolves outside plugin directory", async () =
|
||||
install.mockRestore()
|
||||
cwd.mockRestore()
|
||||
wait.mockRestore()
|
||||
delete process.env.OPENCODE_PLUGIN_META_FILE
|
||||
delete process.env.KILO_PLUGIN_META_FILE
|
||||
}
|
||||
})
|
||||
|
||||
@@ -228,7 +228,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 config: TuiConfig.Info = {
|
||||
plugin: [tmp.extra.spec],
|
||||
plugin_origins: [
|
||||
@@ -252,7 +252,7 @@ test("rejects npm tui plugin that exports server and tui together", async () =>
|
||||
install.mockRestore()
|
||||
cwd.mockRestore()
|
||||
wait.mockRestore()
|
||||
delete process.env.OPENCODE_PLUGIN_META_FILE
|
||||
delete process.env.KILO_PLUGIN_META_FILE
|
||||
}
|
||||
})
|
||||
|
||||
@@ -286,7 +286,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 config: TuiConfig.Info = {
|
||||
plugin: [tmp.extra.spec],
|
||||
plugin_origins: [
|
||||
@@ -316,7 +316,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
|
||||
}
|
||||
})
|
||||
|
||||
@@ -351,7 +351,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 config: TuiConfig.Info = {
|
||||
plugin: [tmp.extra.spec],
|
||||
plugin_origins: [
|
||||
@@ -373,7 +373,7 @@ test("does not use directory package main for tui entry", async () => {
|
||||
await TuiPluginRuntime.dispose()
|
||||
cwd.mockRestore()
|
||||
wait.mockRestore()
|
||||
delete process.env.OPENCODE_PLUGIN_META_FILE
|
||||
delete process.env.KILO_PLUGIN_META_FILE
|
||||
}
|
||||
})
|
||||
|
||||
@@ -398,7 +398,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 config: TuiConfig.Info = {
|
||||
plugin: [tmp.extra.spec],
|
||||
plugin_origins: [
|
||||
@@ -420,7 +420,7 @@ test("uses directory index fallback for tui when package.json is missing", async
|
||||
await TuiPluginRuntime.dispose()
|
||||
cwd.mockRestore()
|
||||
wait.mockRestore()
|
||||
delete process.env.OPENCODE_PLUGIN_META_FILE
|
||||
delete process.env.KILO_PLUGIN_META_FILE
|
||||
}
|
||||
})
|
||||
|
||||
@@ -455,7 +455,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 config: TuiConfig.Info = {
|
||||
plugin: [[tmp.extra.spec, { marker: tmp.extra.marker }]],
|
||||
plugin_origins: [
|
||||
@@ -479,6 +479,6 @@ test("uses npm package name when tui plugin id is omitted", async () => {
|
||||
install.mockRestore()
|
||||
cwd.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 config: TuiConfig.Info = {
|
||||
plugin: [[tmp.extra.spec, { marker: tmp.extra.marker }]],
|
||||
@@ -58,14 +58,14 @@ test("skips external tui plugins in pure mode", async () => {
|
||||
cwd.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
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -506,7 +506,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 config: TuiConfig.Info = {
|
||||
plugin: [
|
||||
[tmp.extra.badSpec, { marker: path.join(tmp.path, "bad.txt") }],
|
||||
@@ -541,7 +541,7 @@ test("continues loading when a plugin is missing config metadata", async () => {
|
||||
await TuiPluginRuntime.dispose()
|
||||
cwd.mockRestore()
|
||||
wait.mockRestore()
|
||||
delete process.env.OPENCODE_PLUGIN_META_FILE
|
||||
delete process.env.KILO_PLUGIN_META_FILE
|
||||
}
|
||||
})
|
||||
|
||||
@@ -598,7 +598,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 {
|
||||
@@ -619,7 +619,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(() => {})
|
||||
@@ -753,7 +753,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()
|
||||
|
||||
@@ -804,13 +804,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 config: TuiConfig.Info = {
|
||||
plugin: [[tmp.extra.spec, { marker: tmp.extra.marker }]],
|
||||
plugin_enabled: {
|
||||
@@ -86,7 +86,7 @@ test("toggles plugin runtime state by exported id", async () => {
|
||||
await TuiPluginRuntime.dispose()
|
||||
cwd.mockRestore()
|
||||
wait.mockRestore()
|
||||
delete process.env.OPENCODE_PLUGIN_META_FILE
|
||||
delete process.env.KILO_PLUGIN_META_FILE
|
||||
}
|
||||
})
|
||||
|
||||
@@ -115,7 +115,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 config: TuiConfig.Info = {
|
||||
plugin: [[tmp.extra.spec, { marker: tmp.extra.marker }]],
|
||||
plugin_enabled: {
|
||||
@@ -152,6 +152,6 @@ test("kv plugin_enabled overrides tui config on startup", async () => {
|
||||
await TuiPluginRuntime.dispose()
|
||||
cwd.mockRestore()
|
||||
wait.mockRestore()
|
||||
delete process.env.OPENCODE_PLUGIN_META_FILE
|
||||
delete process.env.KILO_PLUGIN_META_FILE
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user