refactor: kilo compat for v1.14.29

This commit is contained in:
Mark IJbema
2026-04-29 17:24:20 +02:00
parent 5e67efc2fd
commit 7d375b93ee
1673 changed files with 1498 additions and 399138 deletions
@@ -12,17 +12,17 @@ import { tmpdir } from "../fixture/fixture"
void Log.init({ print: false })
const original = {
OPENCODE_EXPERIMENTAL_HTTPAPI: Flag.OPENCODE_EXPERIMENTAL_HTTPAPI,
OPENCODE_SERVER_PASSWORD: Flag.OPENCODE_SERVER_PASSWORD,
OPENCODE_SERVER_USERNAME: Flag.OPENCODE_SERVER_USERNAME,
KILO_EXPERIMENTAL_HTTPAPI: Flag.KILO_EXPERIMENTAL_HTTPAPI,
KILO_SERVER_PASSWORD: Flag.KILO_SERVER_PASSWORD,
KILO_SERVER_USERNAME: Flag.KILO_SERVER_USERNAME,
}
const methods = ["get", "post", "put", "delete", "patch"] as const
function app(input?: { password?: string; username?: string }) {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = true
Flag.OPENCODE_SERVER_PASSWORD = input?.password
Flag.OPENCODE_SERVER_USERNAME = input?.username
Flag.KILO_EXPERIMENTAL_HTTPAPI = true
Flag.KILO_SERVER_PASSWORD = input?.password
Flag.KILO_SERVER_USERNAME = input?.username
return Server.Default().app
}
@@ -100,9 +100,9 @@ function fileUrl(input?: { directory?: string; token?: string }) {
}
afterEach(async () => {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = original.OPENCODE_EXPERIMENTAL_HTTPAPI
Flag.OPENCODE_SERVER_PASSWORD = original.OPENCODE_SERVER_PASSWORD
Flag.OPENCODE_SERVER_USERNAME = original.OPENCODE_SERVER_USERNAME
Flag.KILO_EXPERIMENTAL_HTTPAPI = original.KILO_EXPERIMENTAL_HTTPAPI
Flag.KILO_SERVER_PASSWORD = original.KILO_SERVER_PASSWORD
Flag.KILO_SERVER_USERNAME = original.KILO_SERVER_USERNAME
await Instance.disposeAll()
await resetDatabase()
})
@@ -144,7 +144,7 @@ describe("HttpApi server", () => {
const response = await app().request(fileUrl(), {
headers: {
"x-opencode-directory": tmp.path,
"x-kilo-directory": tmp.path,
},
})
@@ -157,7 +157,7 @@ describe("HttpApi server", () => {
const response = await app().request("/project/current", {
headers: {
"x-opencode-directory": tmp.path,
"x-kilo-directory": tmp.path,
},
})
@@ -171,18 +171,18 @@ describe("HttpApi server", () => {
const [missing, bad, good] = await Promise.all([
app({ password: "secret" }).request(fileUrl(), {
headers: { "x-opencode-directory": tmp.path },
headers: { "x-kilo-directory": tmp.path },
}),
app({ password: "secret" }).request(fileUrl(), {
headers: {
authorization: authorization("opencode", "wrong"),
"x-opencode-directory": tmp.path,
"x-kilo-directory": tmp.path,
},
}),
app({ password: "secret" }).request(fileUrl(), {
headers: {
authorization: authorization("opencode", "secret"),
"x-opencode-directory": tmp.path,
"x-kilo-directory": tmp.path,
},
}),
])
@@ -200,7 +200,7 @@ describe("HttpApi server", () => {
fileUrl({ token: Buffer.from("opencode:secret").toString("base64") }),
{
headers: {
"x-opencode-directory": tmp.path,
"x-kilo-directory": tmp.path,
},
},
)
@@ -216,7 +216,7 @@ describe("HttpApi server", () => {
const response = await app().request(fileUrl({ directory: query.path }), {
headers: {
"x-opencode-directory": header.path,
"x-kilo-directory": header.path,
},
})
@@ -10,10 +10,10 @@ import { tmpdir } from "../fixture/fixture"
void Log.init({ print: false })
const original = Flag.OPENCODE_EXPERIMENTAL_HTTPAPI
const original = Flag.KILO_EXPERIMENTAL_HTTPAPI
function app() {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = true
Flag.KILO_EXPERIMENTAL_HTTPAPI = true
return Server.Default().app
}
@@ -36,7 +36,7 @@ async function waitDisposed(directory: string) {
}
afterEach(async () => {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = original
Flag.KILO_EXPERIMENTAL_HTTPAPI = original
await Instance.disposeAll()
await resetDatabase()
})
@@ -50,7 +50,7 @@ describe("config HttpApi", () => {
method: "PATCH",
headers: {
"content-type": "application/json",
"x-opencode-directory": tmp.path,
"x-kilo-directory": tmp.path,
},
body: JSON.stringify({ username: "patched-user", formatter: false, lsp: false }),
})
@@ -9,10 +9,10 @@ import { tmpdir } from "../fixture/fixture"
void Log.init({ print: false })
const original = Flag.OPENCODE_EXPERIMENTAL_HTTPAPI
const original = Flag.KILO_EXPERIMENTAL_HTTPAPI
function app() {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = true
Flag.KILO_EXPERIMENTAL_HTTPAPI = true
return Server.Default().app
}
@@ -28,7 +28,7 @@ async function readFirstChunk(response: Response) {
}
afterEach(async () => {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = original
Flag.KILO_EXPERIMENTAL_HTTPAPI = original
await Instance.disposeAll()
await resetDatabase()
})
@@ -36,7 +36,7 @@ afterEach(async () => {
describe("event HttpApi bridge", () => {
test("serves event stream through experimental Effect route", async () => {
await using tmp = await tmpdir({ git: true, config: { formatter: false, lsp: false } })
const response = await app().request(EventPaths.event, { headers: { "x-opencode-directory": tmp.path } })
const response = await app().request(EventPaths.event, { headers: { "x-kilo-directory": tmp.path } })
expect(response.status).toBe(200)
expect(response.headers.get("content-type")).toContain("text/event-stream")
@@ -14,11 +14,11 @@ import { tmpdir } from "../fixture/fixture"
void Log.init({ print: false })
const original = Flag.OPENCODE_EXPERIMENTAL_HTTPAPI
const original = Flag.KILO_EXPERIMENTAL_HTTPAPI
const testWorktreeMutations = process.platform === "win32" ? test.skip : test
function app() {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = true
Flag.KILO_EXPERIMENTAL_HTTPAPI = true
return Server.Default().app
}
@@ -49,7 +49,7 @@ async function waitReady(directory: string) {
}
afterEach(async () => {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = original
Flag.KILO_EXPERIMENTAL_HTTPAPI = original
await Instance.disposeAll()
await resetDatabase()
})
@@ -70,7 +70,7 @@ describe("experimental HttpApi", () => {
},
})
const headers = { "x-opencode-directory": tmp.path }
const headers = { "x-kilo-directory": tmp.path }
const [consoleState, consoleOrgs, toolList, toolIDs, worktrees, resources] = await Promise.all([
app().request(ExperimentalPaths.console, { headers }),
app().request(ExperimentalPaths.consoleOrgs, { headers }),
@@ -126,7 +126,7 @@ describe("experimental HttpApi", () => {
const switched = await app().request(ExperimentalPaths.consoleSwitch, {
method: "POST",
headers: { "x-opencode-directory": tmp.path, "content-type": "application/json" },
headers: { "x-kilo-directory": tmp.path, "content-type": "application/json" },
body: JSON.stringify({ accountID: "account-test", orgID: "org-test" }),
})
@@ -147,7 +147,7 @@ describe("experimental HttpApi", () => {
fn: async () => createSession({ title: "page-two" }),
})
const headers = { "x-opencode-directory": tmp.path }
const headers = { "x-kilo-directory": tmp.path }
const page = await app().request(
`${ExperimentalPaths.session}?${new URLSearchParams({ directory: tmp.path, limit: "1" })}`,
{ headers },
@@ -174,7 +174,7 @@ describe("experimental HttpApi", () => {
testWorktreeMutations("serves worktree mutations through Hono bridge", async () => {
await using tmp = await tmpdir({ git: true, config: { formatter: false, lsp: false } })
const headers = { "x-opencode-directory": tmp.path, "content-type": "application/json" }
const headers = { "x-kilo-directory": tmp.path, "content-type": "application/json" }
const created = await app().request(ExperimentalPaths.worktree, {
method: "POST",
headers,
@@ -20,7 +20,7 @@ function request(route: string, directory: string, query?: Record<string, string
return ExperimentalHttpApiServer.webHandler().handler(
new Request(url, {
headers: {
"x-opencode-directory": directory,
"x-kilo-directory": directory,
},
}),
context,
@@ -11,10 +11,10 @@ import { tmpdir } from "../fixture/fixture"
void Log.init({ print: false })
const original = Flag.OPENCODE_EXPERIMENTAL_HTTPAPI
const original = Flag.KILO_EXPERIMENTAL_HTTPAPI
function app() {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = true
Flag.KILO_EXPERIMENTAL_HTTPAPI = true
return Server.Default().app
}
@@ -37,7 +37,7 @@ async function waitDisposed(directory: string) {
}
afterEach(async () => {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = original
Flag.KILO_EXPERIMENTAL_HTTPAPI = original
await Instance.disposeAll()
await resetDatabase()
})
@@ -51,9 +51,9 @@ describe("instance HttpApi", () => {
vcsDiff.searchParams.set("mode", "git")
const [paths, vcs, diff] = await Promise.all([
app().request(InstancePaths.path, { headers: { "x-opencode-directory": tmp.path } }),
app().request(InstancePaths.vcs, { headers: { "x-opencode-directory": tmp.path } }),
app().request(vcsDiff, { headers: { "x-opencode-directory": tmp.path } }),
app().request(InstancePaths.path, { headers: { "x-kilo-directory": tmp.path } }),
app().request(InstancePaths.vcs, { headers: { "x-kilo-directory": tmp.path } }),
app().request(vcsDiff, { headers: { "x-kilo-directory": tmp.path } }),
])
expect(paths.status).toBe(200)
@@ -72,11 +72,11 @@ describe("instance HttpApi", () => {
await using tmp = await tmpdir({ config: { formatter: false, lsp: false } })
const [commands, agents, skills, lsp, formatter] = await Promise.all([
app().request(InstancePaths.command, { headers: { "x-opencode-directory": tmp.path } }),
app().request(InstancePaths.agent, { headers: { "x-opencode-directory": tmp.path } }),
app().request(InstancePaths.skill, { headers: { "x-opencode-directory": tmp.path } }),
app().request(InstancePaths.lsp, { headers: { "x-opencode-directory": tmp.path } }),
app().request(InstancePaths.formatter, { headers: { "x-opencode-directory": tmp.path } }),
app().request(InstancePaths.command, { headers: { "x-kilo-directory": tmp.path } }),
app().request(InstancePaths.agent, { headers: { "x-kilo-directory": tmp.path } }),
app().request(InstancePaths.skill, { headers: { "x-kilo-directory": tmp.path } }),
app().request(InstancePaths.lsp, { headers: { "x-kilo-directory": tmp.path } }),
app().request(InstancePaths.formatter, { headers: { "x-kilo-directory": tmp.path } }),
])
expect(commands.status).toBe(200)
@@ -101,14 +101,14 @@ describe("instance HttpApi", () => {
const response = await app().request("/project/git/init", {
method: "POST",
headers: { "x-opencode-directory": tmp.path },
headers: { "x-kilo-directory": tmp.path },
})
expect(response.status).toBe(200)
expect(await response.json()).toMatchObject({ vcs: "git", worktree: tmp.path })
await disposed
const current = await app().request("/project/current", { headers: { "x-opencode-directory": tmp.path } })
const current = await app().request("/project/current", { headers: { "x-kilo-directory": tmp.path } })
expect(current.status).toBe(200)
expect(await current.json()).toMatchObject({ vcs: "git", worktree: tmp.path })
})
@@ -116,13 +116,13 @@ describe("instance HttpApi", () => {
test("serves project update through Hono bridge", async () => {
await using tmp = await tmpdir({ config: { formatter: false, lsp: false } })
const current = await app().request("/project/current", { headers: { "x-opencode-directory": tmp.path } })
const current = await app().request("/project/current", { headers: { "x-kilo-directory": tmp.path } })
expect(current.status).toBe(200)
const project = (await current.json()) as { id: string }
const response = await app().request(`/project/${project.id}`, {
method: "PATCH",
headers: { "x-opencode-directory": tmp.path, "content-type": "application/json" },
headers: { "x-kilo-directory": tmp.path, "content-type": "application/json" },
body: JSON.stringify({ name: "patched-project", commands: { start: "bun dev" } }),
})
@@ -133,7 +133,7 @@ describe("instance HttpApi", () => {
commands: { start: "bun dev" },
})
const list = await app().request("/project", { headers: { "x-opencode-directory": tmp.path } })
const list = await app().request("/project", { headers: { "x-kilo-directory": tmp.path } })
expect(list.status).toBe(200)
expect(await list.json()).toContainEqual(
expect.objectContaining({ id: project.id, name: "patched-project", commands: { start: "bun dev" } }),
@@ -154,7 +154,7 @@ describe("instance HttpApi", () => {
const response = await app().request(InstancePaths.dispose, {
method: "POST",
headers: { "x-opencode-directory": tmp.path },
headers: { "x-kilo-directory": tmp.path },
})
expect(response.status).toBe(200)
@@ -15,10 +15,10 @@ import { it } from "../lib/effect"
void Log.init({ print: false })
const original = Flag.OPENCODE_EXPERIMENTAL_HTTPAPI
const original = Flag.KILO_EXPERIMENTAL_HTTPAPI
function app(experimental: boolean) {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = experimental
Flag.KILO_EXPERIMENTAL_HTTPAPI = experimental
return Server.Default().app
}
type TestApp = ReturnType<typeof app>
@@ -83,7 +83,7 @@ function expectJsonParity(input: {
}
afterEach(async () => {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = original
Flag.KILO_EXPERIMENTAL_HTTPAPI = original
await Instance.disposeAll()
await resetDatabase()
})
@@ -93,7 +93,7 @@ describe("HttpApi JSON parity", () => {
"matches legacy JSON shape for session read endpoints",
withTmp({ git: true, config: { formatter: false, lsp: false } }, (tmp) =>
Effect.gen(function* () {
const headers = { "x-opencode-directory": tmp.path }
const headers = { "x-kilo-directory": tmp.path }
const seeded = yield* seedSessions.pipe(Effect.provide(Session.defaultLayer))
const legacy = app(false)
const httpapi = app(true)
@@ -13,19 +13,19 @@ import { testEffect } from "../lib/effect"
void Log.init({ print: false })
const original = Flag.OPENCODE_EXPERIMENTAL_HTTPAPI
const original = Flag.KILO_EXPERIMENTAL_HTTPAPI
const context = Context.empty() as Context.Context<unknown>
const it = testEffect(Layer.mergeAll(NodeFileSystem.layer, NodePath.layer))
function app(experimental: boolean) {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = experimental
Flag.KILO_EXPERIMENTAL_HTTPAPI = experimental
return Server.Default().app
}
type TestApp = ReturnType<typeof app>
function request(route: string, directory: string, init?: RequestInit) {
const headers = new Headers(init?.headers)
headers.set("x-opencode-directory", directory)
headers.set("x-kilo-directory", directory)
return ExperimentalHttpApiServer.webHandler().handler(
new Request(`http://localhost${route}`, {
...init,
@@ -75,7 +75,7 @@ const readResponse = Effect.fnUntraced(function* (input: { app: TestApp; path: s
})
afterEach(async () => {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = original
Flag.KILO_EXPERIMENTAL_HTTPAPI = original
await Instance.disposeAll()
await resetDatabase()
})
@@ -164,7 +164,7 @@ describe("mcp HttpApi", () => {
"matches legacy unsupported OAuth error responses",
withMcpProject((dir) =>
Effect.gen(function* () {
const headers = { "x-opencode-directory": dir }
const headers = { "x-kilo-directory": dir }
const legacy = app(false)
const httpapi = app(true)
@@ -11,14 +11,14 @@ import { testEffect } from "../lib/effect"
void Log.init({ print: false })
const original = Flag.OPENCODE_EXPERIMENTAL_HTTPAPI
const original = Flag.KILO_EXPERIMENTAL_HTTPAPI
const it = testEffect(Layer.mergeAll(NodeFileSystem.layer, NodePath.layer))
const providerID = "test-oauth-parity"
const oauthURL = "https://example.com/oauth"
const oauthInstructions = "Finish OAuth"
function app(experimental: boolean) {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = experimental
Flag.KILO_EXPERIMENTAL_HTTPAPI = experimental
return Server.Default().app
}
@@ -97,7 +97,7 @@ function withProviderProject<A, E, R>(self: (dir: string) => Effect.Effect<A, E,
}
afterEach(async () => {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = original
Flag.KILO_EXPERIMENTAL_HTTPAPI = original
await Instance.disposeAll()
await resetDatabase()
})
@@ -107,7 +107,7 @@ describe("provider HttpApi", () => {
"matches legacy OAuth authorize response shapes",
withProviderProject((dir) =>
Effect.gen(function* () {
const headers = { "x-opencode-directory": dir, "content-type": "application/json" }
const headers = { "x-kilo-directory": dir, "content-type": "application/json" }
const legacy = app(false)
const httpapi = app(true)
@@ -10,16 +10,16 @@ import { tmpdir } from "../fixture/fixture"
void Log.init({ print: false })
const original = Flag.OPENCODE_EXPERIMENTAL_HTTPAPI
const original = Flag.KILO_EXPERIMENTAL_HTTPAPI
const testPty = process.platform === "win32" ? test.skip : test
function app() {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = true
Flag.KILO_EXPERIMENTAL_HTTPAPI = true
return Server.Default().app
}
afterEach(async () => {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = original
Flag.KILO_EXPERIMENTAL_HTTPAPI = original
await Instance.disposeAll()
await resetDatabase()
})
@@ -27,7 +27,7 @@ afterEach(async () => {
describe("pty HttpApi bridge", () => {
test("serves available shell list through experimental Effect routes", async () => {
await using tmp = await tmpdir({ git: true, config: { formatter: false, lsp: false } })
const response = await app().request(PtyPaths.shells, { headers: { "x-opencode-directory": tmp.path } })
const response = await app().request(PtyPaths.shells, { headers: { "x-kilo-directory": tmp.path } })
expect(response.status).toBe(200)
expect(await response.json()).toEqual(
@@ -43,7 +43,7 @@ describe("pty HttpApi bridge", () => {
testPty("serves PTY JSON routes through experimental Effect routes", async () => {
await using tmp = await tmpdir({ git: true, config: { formatter: false, lsp: false } })
const headers = { "x-opencode-directory": tmp.path }
const headers = { "x-kilo-directory": tmp.path }
const list = await app().request(PtyPaths.list, { headers })
expect(list.status).toBe(200)
expect(await list.json()).toEqual([])
@@ -81,7 +81,7 @@ describe("pty HttpApi bridge", () => {
test("returns 404 for missing PTY websocket before upgrade", async () => {
await using tmp = await tmpdir({ git: true, config: { formatter: false, lsp: false } })
const response = await app().request(PtyPaths.connect.replace(":ptyID", PtyID.ascending()), {
headers: { "x-opencode-directory": tmp.path },
headers: { "x-kilo-directory": tmp.path },
})
expect(response.status).toBe(404)
})
@@ -16,10 +16,10 @@ import { it } from "../lib/effect"
void Log.init({ print: false })
const original = Flag.OPENCODE_EXPERIMENTAL_HTTPAPI
const original = Flag.KILO_EXPERIMENTAL_HTTPAPI
function app() {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = true
Flag.KILO_EXPERIMENTAL_HTTPAPI = true
return Server.Default().app
}
@@ -98,7 +98,7 @@ function withTmp<A, E, R>(
}
afterEach(async () => {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = original
Flag.KILO_EXPERIMENTAL_HTTPAPI = original
await Instance.disposeAll()
await resetDatabase()
})
@@ -108,7 +108,7 @@ describe("session HttpApi", () => {
"serves read routes through Hono bridge",
withTmp({ git: true, config: { formatter: false, lsp: false } }, (tmp) =>
Effect.gen(function* () {
const headers = { "x-opencode-directory": tmp.path }
const headers = { "x-kilo-directory": tmp.path }
const parent = yield* createSession(tmp.path, { title: "parent" })
const child = yield* createSession(tmp.path, { title: "child", parentID: parent.id })
const message = yield* createTextMessage(tmp.path, parent.id, "hello")
@@ -171,7 +171,7 @@ describe("session HttpApi", () => {
"serves lifecycle mutation routes through Hono bridge",
withTmp({ git: true, config: { formatter: false, lsp: false, share: "disabled" } }, (tmp) =>
Effect.gen(function* () {
const headers = { "x-opencode-directory": tmp.path, "content-type": "application/json" }
const headers = { "x-kilo-directory": tmp.path, "content-type": "application/json" }
const createdEmpty = yield* requestJson<Session.Info>(SessionPaths.create, {
method: "POST",
@@ -221,7 +221,7 @@ describe("session HttpApi", () => {
"serves message mutation routes through Hono bridge",
withTmp({ git: true, config: { formatter: false, lsp: false } }, (tmp) =>
Effect.gen(function* () {
const headers = { "x-opencode-directory": tmp.path, "content-type": "application/json" }
const headers = { "x-kilo-directory": tmp.path, "content-type": "application/json" }
const session = yield* createSession(tmp.path, { title: "messages" })
const first = yield* createTextMessage(tmp.path, session.id, "first")
const second = yield* createTextMessage(tmp.path, session.id, "second")
@@ -265,7 +265,7 @@ describe("session HttpApi", () => {
"serves remaining non-LLM session mutation routes through Hono bridge",
withTmp({ git: true, config: { formatter: false, lsp: false } }, (tmp) =>
Effect.gen(function* () {
const headers = { "x-opencode-directory": tmp.path, "content-type": "application/json" }
const headers = { "x-kilo-directory": tmp.path, "content-type": "application/json" }
const session = yield* createSession(tmp.path, { title: "remaining" })
expect(
@@ -11,11 +11,11 @@ import { tmpdir } from "../fixture/fixture"
void Log.init({ print: false })
const originalHttpApi = Flag.OPENCODE_EXPERIMENTAL_HTTPAPI
const originalWorkspaces = Flag.OPENCODE_EXPERIMENTAL_WORKSPACES
const originalHttpApi = Flag.KILO_EXPERIMENTAL_HTTPAPI
const originalWorkspaces = Flag.KILO_EXPERIMENTAL_WORKSPACES
function app(httpapi = true) {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = httpapi
Flag.KILO_EXPERIMENTAL_HTTPAPI = httpapi
return Server.Default().app
}
@@ -24,17 +24,17 @@ function runSession<A, E>(fx: Effect.Effect<A, E, Session.Service>) {
}
afterEach(async () => {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = originalHttpApi
Flag.OPENCODE_EXPERIMENTAL_WORKSPACES = originalWorkspaces
Flag.KILO_EXPERIMENTAL_HTTPAPI = originalHttpApi
Flag.KILO_EXPERIMENTAL_WORKSPACES = originalWorkspaces
await Instance.disposeAll()
await resetDatabase()
})
describe("sync HttpApi", () => {
test("serves sync routes through Hono bridge", async () => {
Flag.OPENCODE_EXPERIMENTAL_WORKSPACES = true
Flag.KILO_EXPERIMENTAL_WORKSPACES = true
await using tmp = await tmpdir({ git: true, config: { formatter: false, lsp: false } })
const headers = { "x-opencode-directory": tmp.path, "content-type": "application/json" }
const headers = { "x-kilo-directory": tmp.path, "content-type": "application/json" }
const session = await Instance.provide({
directory: tmp.path,
@@ -82,7 +82,7 @@ describe("sync HttpApi", () => {
test("matches legacy seq validation", async () => {
await using tmp = await tmpdir({ git: true, config: { formatter: false, lsp: false } })
const headers = { "x-opencode-directory": tmp.path, "content-type": "application/json" }
const headers = { "x-kilo-directory": tmp.path, "content-type": "application/json" }
const cases = [
{
path: SyncPaths.history,
@@ -13,10 +13,10 @@ import { tmpdir } from "../fixture/fixture"
void Log.init({ print: false })
const original = Flag.OPENCODE_EXPERIMENTAL_HTTPAPI
const original = Flag.KILO_EXPERIMENTAL_HTTPAPI
function app() {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = true
Flag.KILO_EXPERIMENTAL_HTTPAPI = true
return Server.Default().app
}
@@ -31,7 +31,7 @@ async function expectTrue(path: string, headers: Record<string, string>, body?:
}
afterEach(async () => {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = original
Flag.KILO_EXPERIMENTAL_HTTPAPI = original
await Instance.disposeAll()
await resetDatabase()
})
@@ -48,7 +48,7 @@ describe("tui HttpApi bridge", () => {
test("serves TUI command and event routes through experimental Effect routes", async () => {
await using tmp = await tmpdir({ git: true, config: { formatter: false, lsp: false } })
const headers = { "x-opencode-directory": tmp.path }
const headers = { "x-kilo-directory": tmp.path }
await expectTrue(TuiPaths.appendPrompt, headers, { text: "hello" })
await expectTrue(TuiPaths.openHelp, headers)
@@ -75,7 +75,7 @@ describe("tui HttpApi bridge", () => {
test("serves TUI control queue through experimental Effect routes", async () => {
await using tmp = await tmpdir({ git: true, config: { formatter: false, lsp: false } })
const pending = callTui({ req: { json: async () => ({ value: 1 }), path: "/demo" } } as unknown as Context)
const headers = { "x-opencode-directory": tmp.path }
const headers = { "x-kilo-directory": tmp.path }
const next = await app().request(TuiPaths.controlNext, { headers })
expect(next.status).toBe(200)
@@ -16,13 +16,13 @@ import { Instance } from "../../src/project/instance"
void Log.init({ print: false })
const originalWorkspaces = Flag.OPENCODE_EXPERIMENTAL_WORKSPACES
const originalHttpApi = Flag.OPENCODE_EXPERIMENTAL_HTTPAPI
const originalWorkspaces = Flag.KILO_EXPERIMENTAL_WORKSPACES
const originalHttpApi = Flag.KILO_EXPERIMENTAL_HTTPAPI
function request(path: string, directory: string, init: RequestInit = {}) {
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = true
Flag.KILO_EXPERIMENTAL_HTTPAPI = true
const headers = new Headers(init.headers)
headers.set("x-opencode-directory", directory)
headers.set("x-kilo-directory", directory)
return Server.Default().app.request(path, { ...init, headers })
}
@@ -55,8 +55,8 @@ function localAdaptor(directory: string): WorkspaceAdaptor {
}
afterEach(async () => {
Flag.OPENCODE_EXPERIMENTAL_WORKSPACES = originalWorkspaces
Flag.OPENCODE_EXPERIMENTAL_HTTPAPI = originalHttpApi
Flag.KILO_EXPERIMENTAL_WORKSPACES = originalWorkspaces
Flag.KILO_EXPERIMENTAL_HTTPAPI = originalHttpApi
await Instance.disposeAll()
await resetDatabase()
})
@@ -88,7 +88,7 @@ describe("workspace HttpApi", () => {
})
test("serves mutation endpoints", async () => {
Flag.OPENCODE_EXPERIMENTAL_WORKSPACES = true
Flag.KILO_EXPERIMENTAL_WORKSPACES = true
await using tmp = await tmpdir({ git: true })
await Instance.provide({
directory: tmp.path,
@@ -32,7 +32,7 @@ describe("project.initGit endpoint", () => {
const init = await app.request("/project/git/init", {
method: "POST",
headers: {
"x-opencode-directory": tmp.path,
"x-kilo-directory": tmp.path,
},
})
const body = await init.json()
@@ -50,7 +50,7 @@ describe("project.initGit endpoint", () => {
const current = await app.request("/project/current", {
headers: {
"x-opencode-directory": tmp.path,
"x-kilo-directory": tmp.path,
},
})
expect(current.status).toBe(200)
@@ -90,7 +90,7 @@ describe("project.initGit endpoint", () => {
const init = await app.request("/project/git/init", {
method: "POST",
headers: {
"x-opencode-directory": tmp.path,
"x-kilo-directory": tmp.path,
},
})
expect(init.status).toBe(200)
@@ -105,7 +105,7 @@ describe("project.initGit endpoint", () => {
const current = await app.request("/project/current", {
headers: {
"x-opencode-directory": tmp.path,
"x-kilo-directory": tmp.path,
},
})
expect(current.status).toBe(200)
@@ -36,13 +36,13 @@ afterEach(async () => {
async function withoutWatcher<T>(fn: () => Promise<T>) {
if (process.platform !== "win32") return fn()
const prev = process.env.OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER
process.env.OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER = "true"
const prev = process.env.KILO_EXPERIMENTAL_DISABLE_FILEWATCHER
process.env.KILO_EXPERIMENTAL_DISABLE_FILEWATCHER = "true"
try {
return await fn()
} finally {
if (prev === undefined) delete process.env.OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER
else process.env.OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER = prev
if (prev === undefined) delete process.env.KILO_EXPERIMENTAL_DISABLE_FILEWATCHER
else process.env.KILO_EXPERIMENTAL_DISABLE_FILEWATCHER = prev
}
}