opencode-kilocode-auth 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/plugin.ts +26 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-kilocode-auth",
|
|
3
3
|
"module": "index.ts",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.8",
|
|
5
5
|
"author": "ported from Kilo Code",
|
|
6
6
|
"description": "OpenCode plugin for Kilo Code authentication with support for various models including Giga Potato",
|
|
7
7
|
"files": [
|
package/src/plugin.ts
CHANGED
|
@@ -130,8 +130,33 @@ export async function KilocodeAuthPlugin(input: PluginInput): Promise<Hooks> {
|
|
|
130
130
|
// Map to Kilo Code OpenRouter-compatible endpoint
|
|
131
131
|
// Kilo Code uses: https://api.kilo.ai/api/openrouter/chat/completions
|
|
132
132
|
let url: URL
|
|
133
|
+
let body = init?.body
|
|
134
|
+
|
|
133
135
|
if (parsed.pathname.includes("/chat/completions")) {
|
|
134
136
|
url = new URL(getApiUrl("/api/openrouter/chat/completions", currentToken))
|
|
137
|
+
|
|
138
|
+
// Modify request body to include Kilo Code system prompt prefix
|
|
139
|
+
if (body && typeof body === "string") {
|
|
140
|
+
try {
|
|
141
|
+
const payload = JSON.parse(body)
|
|
142
|
+
if (payload.messages && Array.isArray(payload.messages)) {
|
|
143
|
+
// Find system message and prepend Kilo Code role
|
|
144
|
+
const systemIdx = payload.messages.findIndex((m: any) => m.role === "system")
|
|
145
|
+
const kiloCodeRole = "You are Kilo Code, a highly skilled software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices."
|
|
146
|
+
|
|
147
|
+
if (systemIdx >= 0) {
|
|
148
|
+
// Prepend Kilo Code role to existing system message
|
|
149
|
+
payload.messages[systemIdx].content = kiloCodeRole + "\n\n" + payload.messages[systemIdx].content
|
|
150
|
+
} else {
|
|
151
|
+
// Add system message at the beginning
|
|
152
|
+
payload.messages.unshift({ role: "system", content: kiloCodeRole })
|
|
153
|
+
}
|
|
154
|
+
body = JSON.stringify(payload)
|
|
155
|
+
}
|
|
156
|
+
} catch {
|
|
157
|
+
// Keep original body if parsing fails
|
|
158
|
+
}
|
|
159
|
+
}
|
|
135
160
|
} else if (parsed.pathname.includes("/models")) {
|
|
136
161
|
url = new URL(getApiUrl("/api/openrouter/models", currentToken))
|
|
137
162
|
} else {
|
|
@@ -141,6 +166,7 @@ export async function KilocodeAuthPlugin(input: PluginInput): Promise<Hooks> {
|
|
|
141
166
|
return fetch(url, {
|
|
142
167
|
...init,
|
|
143
168
|
headers,
|
|
169
|
+
body,
|
|
144
170
|
})
|
|
145
171
|
},
|
|
146
172
|
}
|