Files
zhigangYIandzhigangYI bf8faa2f17 kilo 0.1.0: Kilo Code on magpie's Agents page (#90)
New package @magpie-community/agent-kilo 0.1.0 (gangoogle, #90): Kilo Code on magpie's Agents page. connect writes one key, provider.magpie, into ~/.config/kilo/kilo.jsonc: @ai-sdk/openai-compatible at the gateway's /v1, every model magpie offers Kilo with tool_call, the model's own reasoning levels as variants (weakest first, {} when it has none), image input only for a model magpie says takes images, and limit only when the window is known. Library: AGENTS.md, kilo.jsonc mcp (opencode format), skills under ~/.config/kilo. The branch had main merged in (README agent table and registry.json conflicts, both sides kept).

What was run, at 601d2de56c38fe3cc430919d73502dfd96b3b8d8 (b67360c merged with main 10ebbb3):
- HOME=$(mktemp -d) bun test: 2770 pass, 0 fail (packages/kilo 10 pass). bun scripts/check.mjs: clean. PR workflow (test, check, on-npm) green on run 40432034838.
- magpie built from main 65ee8c65c, sandbox HOME, gateway on 3481, one custom provider fakeup whose upstream is a local fake logging every request: fake-chat (context 128000, output 16000, levels stored max,high), fake-vision (64000, vision on), fake-plain (nothing known).
- magpie plugin add packages/kilo, magpie kilo magpie/fakeup/fake-chat on a kilo.jsonc with a comment, $schema, theme, model and a provider of its own: all kept. fake-plain has no limit; fake-chat's variants are high, max.
- @kilocode/cli 7.8.18: kilo models magpie --verbose lists fake-chat with variants [high, max], the other two {}. kilo run --variant=max with a read tool call: the request reached the upstream at /v1/chat/completions with reasoning_effort max and 23 tools, the read went round trip (the file's text came back in the tool message) and the final reply printed. On fake-plain no reasoning_effort was sent. magpie usage counts the calls under agent Kilo Code (ua).
- magpie kilo default after on, a model switch and a turn: kilo.jsonc byte for byte as before (taken after Kilo's own one-time permission migration, which Kilo writes into the file on its first run).

Not tried: a real vision model (every model got image input here because magpie on main describes images for models that don't take them), the VS Code extension at 7.8.18 (the 7.8.8 extension was checked in review), the Library paths with a real Kilo. Found on the way, not this package's: turning an agent plugin off or removing it leaves the agent on magpie with no way back from magpie, for every agent plugin (yetone/magpie#3810).

Co-authored-by: zhigangYI <19320303+gangoogle@users.noreply.github.com>
2026-10-27 09:27:33 +08:00

129 lines
4.8 KiB
JavaScript

import { expect, test } from "bun:test"
import { agent, connect } from "./kilo.agent.js"
test("says where Kilo keeps its model", () => {
expect(agent).toMatchObject({
id: "kilo",
config: "~/.config/kilo/kilo.jsonc",
format: "json",
model: "model",
prefix: "magpie/",
})
})
test("shows Kilo's own icon, as the package gives it", async () => {
const pkg = await Bun.file(new URL("./package.json", import.meta.url)).json()
expect(pkg.magpie.icon).toBe(agent.icon)
expect(pkg.magpie.agent).toBe("./kilo.agent.js")
})
test("points Kilo at magpie as an OpenAI-compatible provider", () => {
const out = connect({
gateway: { url: "http://127.0.0.1:3425", v1: "http://127.0.0.1:3425/v1", key: "magpie-kilo" },
model: { id: "deepseek/deepseek-flash", name: "DeepSeek Flash" },
models: [
{ id: "deepseek/deepseek-flash", name: "DeepSeek Flash", context: 1000000, output: 393216, efforts: ["high", "max"] },
{ id: "trae-cn/glm-5.3-flash", name: "GLM 5.3 Flash", context: 200000, output: 32000 },
],
agent: { id: "kilo", config: "/home/u/.config/kilo/kilo.jsonc" },
})
expect(out).toEqual({
"provider.magpie": {
name: "magpie",
npm: "@ai-sdk/openai-compatible",
options: { baseURL: "http://127.0.0.1:3425/v1", apiKey: "magpie-kilo" },
models: {
"deepseek/deepseek-flash": {
name: "DeepSeek Flash",
tool_call: true,
variants: { high: { reasoningEffort: "high" }, max: { reasoningEffort: "max" } },
limit: { context: 1000000, output: 393216 },
},
"trae-cn/glm-5.3-flash": {
name: "GLM 5.3 Flash",
tool_call: true,
variants: {},
limit: { context: 200000, output: 32000 },
},
},
},
})
})
test("writes a provider with no models when magpie offers none", () => {
const out = connect({
gateway: { url: "http://127.0.0.1:3425", v1: "http://127.0.0.1:3425/v1", key: "k" },
models: [],
agent: { id: "kilo", config: "/home/u/.config/kilo/kilo.jsonc" },
})
expect(out["provider.magpie"].models).toEqual({})
})
const gateway = { v1: "http://127.0.0.1:3425/v1", key: "k" }
const catalogFor = (models) => connect({ gateway, models })["provider.magpie"].models
test("declares image inputs only for image-capable models", () => {
const catalog = catalogFor([
{ id: "vision", images: true },
{ id: "text", images: false },
{ id: "unspecified" },
])
expect(catalog.vision.attachment).toBe(true)
expect(catalog.vision.modalities).toEqual({ input: ["text", "image"], output: ["text"] })
for (const id of ["text", "unspecified"]) {
expect(catalog[id]).not.toHaveProperty("attachment")
expect(catalog[id]).not.toHaveProperty("modalities")
}
})
test("orders and deduplicates the model's own reasoning levels without changing the input", () => {
const efforts = ["ultra", "max", "high", "medium", "low", "minimal", "none", "xhigh", "max"]
const original = [...efforts]
const { variants } = catalogFor([{ id: "reasoner", efforts }]).reasoner
expect(Object.keys(variants)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"])
for (const level of Object.keys(variants)) {
expect(variants[level]).toEqual({ reasoningEffort: level })
}
expect(efforts).toEqual(original)
})
test("keeps unrecognized reasoning levels after known levels", () => {
const { variants } = catalogFor([{ id: "reasoner", efforts: ["custom", "max", "high", "custom"] }]).reasoner
expect(Object.keys(variants)).toEqual(["high", "max", "custom"])
expect(variants.custom).toEqual({ reasoningEffort: "custom" })
})
test("writes empty variants for models without reasoning levels", () => {
const catalog = catalogFor([{ id: "empty", efforts: [] }, { id: "missing" }])
for (const model of Object.values(catalog)) {
expect(model.variants).toEqual({})
expect(model).not.toHaveProperty("reasoning")
}
})
test("omits limits for unknown context windows and preserves known limits", () => {
const catalog = catalogFor([
{ id: "missing", output: 100 },
{ id: "zero", context: 0, output: 100 },
{ id: "negative", context: -1 },
{ id: "known", context: 200000, output: 32000 },
{ id: "unknown-output", context: 200000 },
])
for (const id of ["missing", "zero", "negative"]) {
expect(catalog[id]).not.toHaveProperty("limit")
}
expect(catalog.known.limit).toEqual({ context: 200000, output: 32000 })
expect(catalog["unknown-output"].limit).toEqual({ context: 200000, output: 0 })
})
test("returns the provider as one restorable key even when the model catalog is omitted", () => {
const out = connect({ gateway })
expect(Object.keys(out)).toEqual(["provider.magpie"])
expect(out["provider.magpie"]).toEqual({
name: "magpie",
npm: "@ai-sdk/openai-compatible",
options: { baseURL: gateway.v1, apiKey: gateway.key },
models: {},
})
})