Compare commits

...

1 Commits

Author SHA1 Message Date
Aiden Cline 95e294178d fix(core): select Kimi prompt by provider 2026-08-12 21:59:34 +00:00
2 changed files with 23 additions and 5 deletions
+8 -3
View File
@@ -21,7 +21,9 @@ export const OpenAIPlugin = make("openai", (id) => {
export const GooglePlugin = make("google", (id) => (id.includes("gemini-") ? PROMPT_GEMINI : undefined))
export const AnthropicPlugin = make("anthropic", (id) => (id.includes("claude") ? PROMPT_ANTHROPIC : undefined))
export const KimiPlugin = make("kimi", (id) => (id.includes("kimi") ? PROMPT_KIMI : undefined))
export const KimiPlugin = make("kimi", (id, providerID) =>
id.includes("kimi") || providerID.includes("kimi") ? PROMPT_KIMI : undefined,
)
export const ArceePlugin = make("arcee", (id) => (id.includes("trinity") ? PROMPT_TRINITY : undefined))
export const MetaPlugin = make("meta", (id) => {
if (!id.includes("muse")) return
@@ -31,7 +33,7 @@ export const MetaPlugin = make("meta", (id) => {
export const Plugins = [OpenAIPlugin, GooglePlugin, AnthropicPlugin, KimiPlugin, ArceePlugin, MetaPlugin] as const
function make(id: string, select: (modelID: string) => string | undefined) {
function make(id: string, select: (modelID: string, providerID: string) => string | undefined) {
return define({
id: `opencode.system-prompt.${id}`,
effect: Effect.fn(`SystemPromptPlugin.${id}`)(function* (ctx) {
@@ -43,7 +45,10 @@ function make(id: string, select: (modelID: string) => string | undefined) {
const model = (yield* ctx.catalog.model.list()).data.find(
(model) => model.providerID === event.model.providerID && model.id === event.model.id,
)
const prompt = select(`${model?.modelID ?? event.model.id} ${model?.family ?? ""}`.toLowerCase())
const prompt = select(
`${model?.modelID ?? event.model.id} ${model?.family ?? ""}`.toLowerCase(),
event.model.providerID.toLowerCase(),
)
if (!prompt) return
event.system[0] = { ...system, text: prompt }
}).pipe(Effect.catch(() => Effect.void)),
@@ -25,10 +25,10 @@ const makeHost = Effect.gen(function* () {
return yield* PluginHost.make(plugins)
})
const context = (id: string, system = fallback): SessionHooks["context"] => ({
const context = (id: string, system = fallback, providerID = "test"): SessionHooks["context"] => ({
sessionID: Session.ID.make("ses_system_prompt"),
agent: Agent.ID.make("build"),
model: Model.Ref.make({ providerID: Provider.ID.make("test"), id: Model.ID.make(id) }),
model: Model.Ref.make({ providerID: Provider.ID.make(providerID), id: Model.ID.make(id) }),
system: [SystemPart.make(system)],
messages: [],
tools: {},
@@ -120,6 +120,19 @@ describe("SystemPromptPlugin", () => {
}),
)
it.effect("selects the Kimi prompt through the official provider", () =>
Effect.gen(function* () {
const hooks = yield* PluginHooks.Service
const pluginHost = yield* makeHost
yield* SystemPromptPlugin.KimiPlugin.effect(pluginHost)
const event = context("k3", fallback, "kimi-for-coding")
yield* hooks.trigger("session", "context", event)
expect(event.system[0]?.text).toContain("# Prompt and Tool Use")
}),
)
it.effect("preserves an explicit agent system prompt", () =>
Effect.gen(function* () {
const agents = yield* Agent.Service