mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-29 03:44:06 +08:00
refactor: replace x-opencode-* headers with x-kilo-* across codebase and upstream scripts
Update upstream merge scripts to use a generic x-opencode- → x-kilo- regex that catches all current and future headers automatically. Apply the same replacement to all source files so the codebase is ready for the next upstream merge.
This commit is contained in:
@@ -38,7 +38,7 @@ export const WorktreeAdaptor: Adaptor = {
|
||||
const { WorkspaceServer } = await import("../workspace-server/server")
|
||||
const url = input instanceof Request || input instanceof URL ? input : new URL(input, "http://kilo.internal")
|
||||
const headers = new Headers(init?.headers ?? (input instanceof Request ? input.headers : undefined))
|
||||
headers.set("x-opencode-directory", config.directory)
|
||||
headers.set("x-kilo-directory", config.directory)
|
||||
|
||||
const request = new Request(url, { ...init, headers })
|
||||
return WorkspaceServer.App().fetch(request)
|
||||
|
||||
@@ -20,8 +20,8 @@ export namespace WorkspaceServer {
|
||||
|
||||
return new Hono()
|
||||
.use(async (c, next) => {
|
||||
const workspaceID = c.req.query("workspace") || c.req.header("x-opencode-workspace")
|
||||
const raw = c.req.query("directory") || c.req.header("x-opencode-directory")
|
||||
const workspaceID = c.req.query("workspace") || c.req.header("x-kilo-workspace")
|
||||
const raw = c.req.query("directory") || c.req.header("x-kilo-directory")
|
||||
if (workspaceID == null) {
|
||||
throw new Error("workspaceID parameter is required")
|
||||
}
|
||||
|
||||
@@ -213,8 +213,8 @@ export namespace Server {
|
||||
)
|
||||
.use(async (c, next) => {
|
||||
if (c.req.path === "/log") return next()
|
||||
const workspaceID = c.req.query("workspace") || c.req.header("x-opencode-workspace")
|
||||
const raw = c.req.query("directory") || c.req.header("x-opencode-directory") || process.cwd()
|
||||
const workspaceID = c.req.query("workspace") || c.req.header("x-kilo-workspace")
|
||||
const raw = c.req.query("directory") || c.req.header("x-kilo-directory") || process.cwd()
|
||||
const directory = Filesystem.resolve(
|
||||
(() => {
|
||||
try {
|
||||
|
||||
@@ -226,9 +226,9 @@ export namespace LLM {
|
||||
headers: {
|
||||
...(input.model.providerID.startsWith("opencode")
|
||||
? {
|
||||
"x-opencode-project": Instance.project.id,
|
||||
"x-opencode-session": input.sessionID,
|
||||
"x-opencode-request": input.user.id,
|
||||
"x-kilo-project": Instance.project.id,
|
||||
"x-kilo-session": input.sessionID,
|
||||
"x-kilo-request": input.user.id,
|
||||
"x-kilo-client": Flag.KILO_CLIENT,
|
||||
}
|
||||
: input.model.providerID !== "anthropic"
|
||||
|
||||
@@ -22,8 +22,8 @@ describe("control-plane/workspace-server SSE", () => {
|
||||
const response = await app.request("/event", {
|
||||
signal: stop.signal,
|
||||
headers: {
|
||||
"x-opencode-workspace": "wrk_test_workspace",
|
||||
"x-opencode-directory": tmp.path,
|
||||
"x-kilo-workspace": "wrk_test_workspace",
|
||||
"x-kilo-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()
|
||||
@@ -51,7 +51,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)
|
||||
@@ -88,7 +88,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)
|
||||
@@ -103,7 +103,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)
|
||||
|
||||
@@ -21,7 +21,7 @@ export function createKiloClient(config?: Config & { directory?: string }) {
|
||||
if (config?.directory) {
|
||||
config.headers = {
|
||||
...config.headers,
|
||||
"x-opencode-directory": encodeURIComponent(config.directory),
|
||||
"x-kilo-directory": encodeURIComponent(config.directory),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,14 +23,14 @@ export function createKiloClient(config?: Config & { directory?: string; experim
|
||||
const encodedDirectory = isNonASCII ? encodeURIComponent(config.directory) : config.directory
|
||||
config.headers = {
|
||||
...config.headers,
|
||||
"x-opencode-directory": encodedDirectory,
|
||||
"x-kilo-directory": encodedDirectory,
|
||||
}
|
||||
}
|
||||
|
||||
if (config?.experimental_workspaceID) {
|
||||
config.headers = {
|
||||
...config.headers,
|
||||
"x-opencode-workspace": config.experimental_workspaceID,
|
||||
"x-kilo-workspace": config.experimental_workspaceID,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ const STRING_REPLACEMENTS: StringReplacement[] = [
|
||||
// Binary name references (be careful with these)
|
||||
{ pattern: /\bopencode upgrade\b/g, replacement: "kilo upgrade" },
|
||||
|
||||
// HTTP header prefix
|
||||
{ pattern: /x-opencode-/g, replacement: "x-kilo-" },
|
||||
|
||||
// Environment variables (exclude OPENCODE_API_KEY - upstream Zen SaaS key)
|
||||
{ pattern: /\bOPENCODE_(?!API_KEY\b)([A-Z_]+)\b/g, replacement: "KILO_$1" },
|
||||
{ pattern: /\bVITE_OPENCODE_/g, replacement: "VITE_KILO_" },
|
||||
|
||||
@@ -122,9 +122,9 @@ const BRANDING_REPLACEMENTS: BrandingReplacement[] = [
|
||||
description: "Window global",
|
||||
},
|
||||
{
|
||||
pattern: /x-opencode-client/g,
|
||||
replacement: "x-kilo-client",
|
||||
description: "HTTP header",
|
||||
pattern: /x-opencode-/g,
|
||||
replacement: "x-kilo-",
|
||||
description: "HTTP header prefix",
|
||||
},
|
||||
{
|
||||
pattern: /_EXTENSION_OPENCODE_/g,
|
||||
|
||||
Reference in New Issue
Block a user