diff --git a/internal/agent/omp.go b/internal/agent/omp.go index cbb866d15..8401dd82f 100644 --- a/internal/agent/omp.go +++ b/internal/agent/omp.go @@ -359,6 +359,18 @@ func ompAt(at place, dir string, entry func() ompProviderEntry) *Agent { role("plan", "plan", "plan", true), role("vision", "vision", "vision", true), role("advisor", "advisor", "advisor", true), + // the rest of omp's chat roles (CHAT_MODEL_ROLE_IDS in pi-tui's + // model-browser.ts, 18.6 to 18.8.8; #1397 named commit and tiny): + // commit writes commit messages and falls to smol when unset + // (commit/model-selection.ts), tiny names sessions and classifies + // and takes smol's model, memory takes tiny's, else smol's + // (ROLE_CONFIGURED_FALLBACK). omp's other roles (KIND_ROLE_IDS) + // are for kinds of model other than the chat models magpie writes + // for omp: image making, web search, speech, dictation, and the + // judge its find tool turns on for a TypeSafe jev model + role("commit", "commit", "commit", true), + role("tiny", "tiny", "tiny", true), + role("memory", "memory", "memory", true), } // each role but the default one has a thinking level of its own, the // ":level" omp reads off the end of the role's model diff --git a/internal/agent/omp_role_thinking_test.go b/internal/agent/omp_role_thinking_test.go index 829bdcc94..23be4b270 100644 --- a/internal/agent/omp_role_thinking_test.go +++ b/internal/agent/omp_role_thinking_test.go @@ -128,3 +128,70 @@ func TestOmpRoleThinking(t *testing.T) { t.Fatal("magpie's provider stayed with no role on it") } } + +// #1397 (KKKKKKKEM, after v0.1.1164): commit and tiny were still missing. +// Every one of omp's chat roles, as CHAT_MODEL_ROLE_IDS in its pi-tui +// model-browser.ts lists them (18.6.1 to 18.8.8), is a field of the row +// with a thinking level of its own but the default one; a role the user had +// set off magpie comes back when magpie's is reset. +func TestOmpEveryChatRole(t *testing.T) { + home := t.TempDir() + t.Setenv("HOME", home) + t.Setenv("USERPROFILE", home) + t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config")) + t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache")) + t.Setenv("PATH", t.TempDir()) + for _, k := range []string{"PI_CODING_AGENT_DIR", "PI_CONFIG_DIR", "OMP_PROFILE", "PI_PROFILE"} { + t.Setenv(k, "") + } + if err := provider.Save(provider.Provider{ID: "deepseek", Name: "DeepSeek", Chat: "https://api.deepseek.com/v1", Key: "k", Models: []string{"pro", "flash"}}); err != nil { + t.Fatal(err) + } + dir := filepath.Join(home, ".omp", "agent") + configPath := filepath.Join(dir, "config.yml") + os.MkdirAll(dir, 0o755) + os.WriteFile(configPath, []byte("modelRoles:\n tiny: openai/gpt-6-mini\n"), 0o644) + a := omp(home) + role := func(name string) string { v, _ := edit.GetYAML(configPath, "modelRoles."+name); return v } + + // omp's name for the role → magpie's field key + chat := map[string]string{ + "default": "model", "smol": "small", "slow": "slow", "vision": "vision", "plan": "plan", + "commit": "commit", "tiny": "tiny", "memory": "memory", "task": "subagent", "advisor": "advisor", + } + for name, key := range chat { + f := a.Field(key) + if f == nil || f.Quiet == (name == "default") { + t.Fatalf("omp's %s role: %+v", name, f) + } + if err := a.Apply(key, "magpie/deepseek/pro"); err != nil { + t.Fatalf("%s: %v", name, err) + } + if got := role(name); got != "magpie/deepseek/pro" { + t.Fatalf("modelRoles.%s: %q", name, got) + } + if name == "default" { + continue + } + if err := a.Apply(key+"_thinking", "high"); err != nil { + t.Fatalf("%s thinking: %v", name, err) + } + if got := role(name); got != "magpie/deepseek/pro:high" { + t.Fatalf("modelRoles.%s at high: %q", name, got) + } + } + for _, k := range []string{"commit", "tiny", "memory"} { + if f := a.Field(k); f.Label != k { + t.Fatalf("%s is labelled %q", k, f.Label) + } + if err := a.Apply(k, ""); err != nil { + t.Fatal(err) + } + } + if got := role("tiny"); got != "openai/gpt-6-mini" { + t.Fatalf("the user's own tiny role not put back: %q", got) + } + if got := role("commit") + role("memory"); got != "" { + t.Fatalf("commit and memory reset: %q", got) + } +} diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 022ed6595..fc407de75 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -2936,11 +2936,16 @@ const TIER_EFFORTS = TIERS.map((tier) => tier + " effort"); const FOLLOWS_MODEL = [...TIERS, "subagents", "smol", "slow"]; // omp's roles share one square as Claude Code's tiers do (#1397), each // with its thinking level under its model: the level omp reads off the end -// of the role's model ("…:high"). plan, vision and advisor don't follow -// the model: unset, omp picks for each itself, the advisor the slow -// role's model first -const OMP_ROLES = ["subagents", "smol", "slow", "plan", "vision", "advisor"]; -const OMP_OWN_PICK = ["plan", "vision", "advisor"]; +// of the role's model ("…:high"). The roles after slow don't follow the +// model; each says what omp does when it is unset: plan and vision are +// omp's own pick, the advisor the slow role's model first, commit and tiny +// the smol role's, memory the tiny role's (omp's chat roles, #1397) +const OMP_UNSET = { + plan: "omp's own pick", vision: "omp's own pick", advisor: "the slow role's model, else omp's own pick", + commit: "the smol role's model", tiny: "the smol role's model", memory: "the tiny role's model, else the smol role's", +}; +const OMP_OWN_PICK = Object.keys(OMP_UNSET); +const OMP_ROLES = ["subagents", "smol", "slow", ...OMP_OWN_PICK]; // omp, a named profile of it (omp#) or either in a WSL distro const ompAgent = (a) => a.id.split("@wsl:")[0].split("#")[0] === "omp"; // the roles an agent's square lists, and whether a field is one of them or @@ -3060,8 +3065,7 @@ function tierMenu(a) { // Claude model of that tier magpie serves, else on the chat's model const main = a.fields.find((f) => f.key === "model"); const mainName = main && (optionFor(main, main.value)?.label || main.value); - const unset = (f) => omp && f.label === "advisor" ? t("the slow role's model, else omp's own pick") - : omp && OMP_OWN_PICK.includes(f.label) ? t("omp's own pick") + const unset = (f) => omp && OMP_OWN_PICK.includes(f.label) ? t(OMP_UNSET[f.label]) : main ? t("same as model ({model})", { model: mainName }) : t("a Claude model of the tier, else the chat's model"); // a tier's effort, offered while there are levels to pick (Claude Code // through magpie); unset, the tier runs at the effort Claude Code asks. @@ -3790,8 +3794,7 @@ function openPicker(agent, field, anchor, ev, only) { : PICKS_ITSELF.includes(agent.id) && field.key === "model" ? "clears the default model; {agent} picks one on its own" : field.label === MEMORIES ? MEMORIES_DEFAULT : field.label === SUB_MODEL ? "each subagent on the model {agent}'s lead asks for" - : ompAgent(agent) && field.label === "advisor" ? "the slow role's model, else omp's own pick" - : ompAgent(agent) && OMP_OWN_PICK.includes(field.label) ? "omp's own pick" + : ompAgent(agent) && OMP_OWN_PICK.includes(field.label) ? OMP_UNSET[field.label] : asideAccount(agent, field) ? "the account active in {agent}" : "what {agent} ships with"; options.unshift({ value: "", label: t("Default"), note: t(note, { agent: agent.name, field: t(field.label) }), icon: agent.icon, reset: true }); diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index 56651aa51..7f3ed5be9 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -31,6 +31,14 @@ const I18N = { "advisor thinking": "顾问思考", "omp's own pick": "由 omp 自己挑选", "the slow role's model, else omp's own pick": "慢模型角色的模型,未设置时由 omp 自己挑选", + "commit": "提交", + "tiny": "微模型", + "memory": "记忆", + "commit thinking": "提交思考", + "tiny thinking": "微模型思考", + "memory thinking": "记忆思考", + "the smol role's model": "小模型角色的模型", + "the tiny role's model, else the smol role's": "微模型角色的模型,未设置时用小模型角色的", "the session's thinking level": "跟随会话的思考强度", "You set {value}; the model's {window} comes first": "你设置的是 {value},但模型的 {window} 优先", "Auto-compact": "自动压缩", @@ -4124,6 +4132,14 @@ const I18N = { "advisor thinking": "顧問思考", "omp's own pick": "由 omp 自己挑選", "the slow role's model, else omp's own pick": "慢模型角色的模型,未設定時由 omp 自己挑選", + "commit": "提交", + "tiny": "微模型", + "memory": "記憶", + "commit thinking": "提交思考", + "tiny thinking": "微模型思考", + "memory thinking": "記憶思考", + "the smol role's model": "小模型角色的模型", + "the tiny role's model, else the smol role's": "微模型角色的模型,未設定時用小模型角色的", "the session's thinking level": "跟隨工作階段的思考強度", "You set {value}; the model's {window} comes first": "你設定的是 {value},但模型的 {window} 優先", "Auto-compact": "自動壓縮", @@ -8200,6 +8216,14 @@ const I18N = { "advisor thinking": "アドバイザーの思考", "omp's own pick": "omp が自分で選ぶ", "the slow role's model, else omp's own pick": "slow ロールのモデル、未設定なら omp が自分で選ぶ", + "commit": "コミット", + "tiny": "極小", + "memory": "メモリー", + "commit thinking": "コミットの思考", + "tiny thinking": "極小の思考", + "memory thinking": "メモリーの思考", + "the smol role's model": "smol ロールのモデル", + "the tiny role's model, else the smol role's": "tiny ロールのモデル、未設定なら smol ロールのモデル", "the session's thinking level": "セッションの思考レベル", "You set {value}; the model's {window} comes first": "設定は {value} ですが、モデルの {window} が優先されます", "Auto-compact": "自動コンパクト", @@ -12278,6 +12302,14 @@ const I18N = { "advisor thinking": "Thinking Berater", "omp's own pick": "wählt omp selbst", "the slow role's model, else omp's own pick": "das Modell der Rolle slow, sonst wählt omp selbst", + "commit": "Commit", + "tiny": "winzig (tiny)", + "memory": "Gedächtnis", + "commit thinking": "Thinking Commit", + "tiny thinking": "Thinking winzig (tiny)", + "memory thinking": "Thinking Gedächtnis", + "the smol role's model": "das Modell der Rolle smol", + "the tiny role's model, else the smol role's": "das Modell der Rolle tiny, sonst das der Rolle smol", "the session's thinking level": "das Thinking-Level der Sitzung", "You set {value}; the model's {window} comes first": "Du hast {value} gesetzt; das Fenster des Modells ({window}) hat Vorrang", "Auto-compact": "Auto-Kompaktierung", diff --git a/internal/gui/tests/omp-roles.test.cjs b/internal/gui/tests/omp-roles.test.cjs index 3c5bd64f6..499a1e448 100644 --- a/internal/gui/tests/omp-roles.test.cjs +++ b/internal/gui/tests/omp-roles.test.cjs @@ -1,14 +1,14 @@ // Run with Node's test runner and Playwright on the module path; see README.md. // omp's roles share one square after the model picker, as Claude Code's -// tiers do (#325, #1397): subagents, smol, slow, plan, vision and advisor, -// each with the model it is on or what it takes unset, and a role on one +// tiers do (#325, #1397): subagents, smol, slow, plan, vision, advisor, +// commit, tiny and memory (every chat role omp 18.8 has), each with the model it is on or what it takes unset, and a role on one // model has its thinking level under it (KKKKKKKEM: the slow role at its // own level). Picking a role opens the model picker for it, "Same as model" // first for a role that follows the model; picking its level opens the // level slider, which writes that role's level. OpenCode's small model, // which doesn't follow the model, stays a picker; a named profile of omp // (omp#work) has the same square. In the connected agent's -// opened row, in English and Chinese, wide and at 390px. +// opened row, in English, Chinese, Japanese and German, wide and at 390px. // No backend: the API is faked here. const assert = require("node:assert/strict"); const fs = require("node:fs/promises"); @@ -37,6 +37,9 @@ const fresh = () => ({ field("plan", "plan", ""), level("plan", "plan", false), field("vision", "vision", ""), level("vision", "vision", false), field("advisor", "advisor", ""), level("advisor", "advisor", false), + field("commit", "commit", ""), level("commit", "commit", false), + field("tiny", "tiny", ""), level("tiny", "tiny", false), + field("memory", "memory", ""), level("memory", "memory", false), { key: "effort", label: "thinking", value: "", options: LEVELS.filter((l) => l.value !== "off") }, ], }, @@ -80,22 +83,36 @@ function server(lang, sets) { // the words as i18n.js has them const W = { en: { - roles: ["subagents", "smol", "slow", "slow thinking", "plan", "vision", "advisor"], + roles: ["subagents", "smol", "slow", "slow thinking", "plan", "vision", "advisor", "commit", "tiny", "memory"], follows: "same as model (DeepSeek Pro)", own: "omp's own pick", advisor: "the slow role's model, else omp's own pick", + smol: "the smol role's model", memory: "the tiny role's model, else the smol role's", session: "the session's thinking level", same: "Same as model", summary: "roles: slow", high: "high", summarySet: "roles: slow (high)", }, zh: { - roles: ["子代理", "小模型", "慢模型", "慢模型思考", "规划", "视觉", "顾问"], + roles: ["子代理", "小模型", "慢模型", "慢模型思考", "规划", "视觉", "顾问", "提交", "微模型", "记忆"], follows: "同主模型(DeepSeek Pro)", own: "由 omp 自己挑选", advisor: "慢模型角色的模型,未设置时由 omp 自己挑选", + smol: "小模型角色的模型", memory: "微模型角色的模型,未设置时用小模型角色的", session: "跟随会话的思考强度", same: "同主模型", summary: "角色:慢模型", high: "高", summarySet: "角色:慢模型 (高)", }, + ja: { + summary: "ロール:低速", + roles: ["サブエージェント", "小", "低速", "低速の思考", "プラン", "ビジョン", "アドバイザー", "コミット", "極小", "メモリー"], + own: "omp が自分で選ぶ", advisor: "slow ロールのモデル、未設定なら omp が自分で選ぶ", + smol: "smol ロールのモデル", memory: "tiny ロールのモデル、未設定なら smol ロールのモデル", + }, + de: { + summary: "Rollen: langsam", + roles: ["Subagenten", "klein (smol)", "langsam", "Thinking langsam", "Planung", "Vision", "Berater", "Commit", "winzig (tiny)", "Gedächtnis"], + own: "wählt omp selbst", advisor: "das Modell der Rolle slow, sonst wählt omp selbst", + smol: "das Modell der Rolle smol", memory: "das Modell der Rolle tiny, sonst das der Rolle smol", + }, }; const omp = '.row.agent[data-id="omp"]'; const items = (page) => page.locator("#pop:not([hidden]) #list li").evaluateAll((es) => es.map((e) => [e.querySelector(".v")?.textContent, e.querySelector(".n")?.textContent || ""])); for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { - for (const width of [1100, 390]) for (const lang of ["en", "zh"]) { + for (const width of [1100, 390]) for (const lang of ["en", "zh", "ja", "de"]) { test(`${engine} ${lang} ${width}px: omp's roles and their thinking levels are one square, OpenCode's small model is a picker`, async (t) => { const w = W[lang]; const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); @@ -131,7 +148,27 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await page.locator("#pop:not([hidden]) #list li").first().waitFor(); const rows = await items(page); assert.deepEqual(rows.map((r) => r[0]), w.roles); - assert.deepEqual(rows.map((r) => r[1]), [w.follows, w.follows, "DeepSeek Flash", w.session, w.own, w.own, w.advisor]); + assert.deepEqual(rows.slice(4).map((r) => r[1]), [w.own, w.own, w.advisor, w.smol, w.smol, w.memory]); + // commit's picker: Default says what omp takes unset, the smol + // role's model, and no "Same as model" + const commitPicker = async () => { + if (!(await page.locator("#pop:not([hidden]) #list li").count())) await square.click(); + const at = (await items(page)).findIndex((r) => r[0] === w.roles[7]); + await page.locator("#pop:not([hidden]) #list li").nth(at).click(); + await page.locator("#pop:not([hidden]) #list li", { hasText: "DeepSeek Flash" }).first().waitFor(); + const top = await page.locator("#pop:not([hidden]) #list li").first().innerText(); + assert.ok(top.includes(w.smol), top); + await page.keyboard.press("Escape"); + await page.waitForFunction(() => !document.querySelector("#pop:not([hidden])")); + }; + // ja and de check the new roles' words; the rest of the walk is en's and zh's + if (!w.follows) { + await commitPicker(); + assert.deepEqual(sets, []); + assert.deepEqual(errors, []); + return; + } + assert.deepEqual(rows.slice(0, 4).map((r) => r[1]), [w.follows, w.follows, "DeepSeek Flash", w.session]); // slow's level: the slider, which writes slow_thinking await page.locator("#pop:not([hidden]) #list li").nth(3).click(); @@ -167,6 +204,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await page.keyboard.press("Escape"); assert.equal(await page.evaluate(() => scrollY), y, "a click scrolled the page"); + await commitPicker(); + // omp's named profile: its roles share the square as well const work = '.row.agent[data-id="omp#work"]'; await page.locator(`${work} .ag-link`).click();