mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-10-30 19:32:39 +08:00
refactor(prompts): hoist Kilo model-specific prompt checks to the front (#9815)
* refactor(cli): hoist Kilo model-specific prompt checks to the front Extract the Kilo metadata-driven prompt selection into a dedicated kiloPrompt() helper and invoke it with an early return at the top of provider(). This ensures Kilo-specific prompt routing takes priority over upstream heuristics and leaves the upstream if-chain untouched, reducing future merge conflicts when opencode adjusts its own model-specific prompt branching. No behavior change. * fix(cli): preserve Ling prompt fallback precedence * fix(cli): keep prompt annotations scoped --------- Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com> Co-authored-by: marius-kilocode <marius@kilocode.ai>
This commit is contained in:
co-authored by
kiloconnect[bot]
marius-kilocode
parent
7ad1bf66d0
commit
b8b915739c
@@ -37,24 +37,30 @@ export function soul() {
|
||||
|
||||
export function provider(model: Provider.Model) {
|
||||
// kilocode_change start
|
||||
switch (model.prompt) {
|
||||
case "anthropic":
|
||||
return [PROMPT_ANTHROPIC]
|
||||
case "anthropic_without_todo":
|
||||
return [PROMPT_DEFAULT]
|
||||
case "beast":
|
||||
return [PROMPT_BEAST]
|
||||
case "codex":
|
||||
return [PROMPT_CODEX]
|
||||
case "gemini":
|
||||
return [PROMPT_GEMINI]
|
||||
case "gpt55":
|
||||
return [PROMPT_GPT55]
|
||||
case "ling":
|
||||
return [PROMPT_LING]
|
||||
case "trinity":
|
||||
return [PROMPT_TRINITY]
|
||||
function prompt() {
|
||||
switch (model.prompt) {
|
||||
case "anthropic":
|
||||
return [PROMPT_ANTHROPIC]
|
||||
case "anthropic_without_todo":
|
||||
return [PROMPT_DEFAULT]
|
||||
case "beast":
|
||||
return [PROMPT_BEAST]
|
||||
case "codex":
|
||||
return [PROMPT_CODEX]
|
||||
case "gemini":
|
||||
return [PROMPT_GEMINI]
|
||||
case "gpt55":
|
||||
return [PROMPT_GPT55]
|
||||
case "ling":
|
||||
return [PROMPT_LING]
|
||||
case "trinity":
|
||||
return [PROMPT_TRINITY]
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
const kilo = prompt()
|
||||
if (kilo) return kilo
|
||||
// kilocode_change end
|
||||
|
||||
if (model.api.id.includes("gpt-4") || model.api.id.includes("o1") || model.api.id.includes("o3"))
|
||||
|
||||
@@ -9,6 +9,7 @@ import PROMPT_CODEX from "../../src/session/prompt/codex.txt"
|
||||
import PROMPT_GEMINI from "../../src/session/prompt/gemini.txt"
|
||||
import PROMPT_GPT from "../../src/session/prompt/gpt.txt"
|
||||
import PROMPT_GPT55 from "../../src/session/prompt/kilocode-gpt-5.5.txt"
|
||||
import PROMPT_LING from "../../src/session/prompt/ling.txt"
|
||||
import PROMPT_TRINITY from "../../src/session/prompt/trinity.txt"
|
||||
|
||||
describe("SystemPrompt.provider", () => {
|
||||
@@ -78,6 +79,24 @@ describe("SystemPrompt.provider", () => {
|
||||
expect(result).toEqual([PROMPT_ANTHROPIC])
|
||||
})
|
||||
|
||||
test("Ling fallback runs after upstream model id heuristics", () => {
|
||||
const model = ProviderTest.model({
|
||||
prompt: undefined,
|
||||
api: { id: "gpt-5-ling", url: "https://example.com", npm: "@ai-sdk/openai" },
|
||||
})
|
||||
const result = SystemPrompt.provider(model)
|
||||
expect(result).toEqual([PROMPT_GPT])
|
||||
})
|
||||
|
||||
test("Ling fallback is selected after upstream heuristics miss", () => {
|
||||
const model = ProviderTest.model({
|
||||
prompt: undefined,
|
||||
api: { id: "ling-2", url: "https://example.com", npm: "@ai-sdk/openai" },
|
||||
})
|
||||
const result = SystemPrompt.provider(model)
|
||||
expect(result).toEqual([PROMPT_LING])
|
||||
})
|
||||
|
||||
test("GPT-5.5 model ids are not prompt-special without metadata", () => {
|
||||
const model = ProviderTest.model({
|
||||
prompt: undefined,
|
||||
|
||||
Reference in New Issue
Block a user