mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-05-06 22:01:44 +08:00
cc-switch could already persist arbitrary OMO Slim agent keys and top-level fields, but the built-in metadata and UI copy still reflected the pre-council agent set. This made the upstream council feature look unsupported and pushed users toward manual JSON-only setup. Promote council to a built-in OMO Slim agent, add copy that points top-level plugin settings at Other Fields, and lock the behavior with regression tests. Constraint: oh-my-opencode-slim exposes council through both agents.council and top-level council config Rejected: Add a dedicated council editor UI now | too much surface area for issue #1981 Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep OMO Slim built-in agent metadata aligned with upstream agent additions before shipping UI support Tested: pnpm exec vitest run tests/utils/omoConfig.test.ts tests/components/OmoFormFields.mergeCustomModelsIntoStore.test.ts Tested: pnpm typecheck Not-tested: End-to-end validation against a live oh-my-opencode-slim installation Related: farion1231/cc-switch#1981
69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
buildOmoProfilePreview,
|
|
buildOmoSlimProfilePreview,
|
|
OMO_SLIM_BUILTIN_AGENTS,
|
|
OMO_SLIM_DISABLEABLE_AGENTS,
|
|
parseOmoOtherFieldsObject,
|
|
} from "@/types/omo";
|
|
|
|
describe("parseOmoOtherFieldsObject", () => {
|
|
it("解析对象 JSON", () => {
|
|
expect(parseOmoOtherFieldsObject('{ "foo": 1 }')).toEqual({ foo: 1 });
|
|
});
|
|
|
|
it("数组/字符串返回 undefined", () => {
|
|
expect(parseOmoOtherFieldsObject('["a"]')).toBeUndefined();
|
|
expect(parseOmoOtherFieldsObject('"hello"')).toBeUndefined();
|
|
});
|
|
|
|
it("非法 JSON 抛出异常", () => {
|
|
expect(() => parseOmoOtherFieldsObject("{")).toThrow();
|
|
});
|
|
});
|
|
|
|
describe("buildOmoProfilePreview", () => {
|
|
it("只合并 otherFields 的对象值,忽略数组", () => {
|
|
const fromArray = buildOmoProfilePreview({}, {}, '["a", "b"]');
|
|
expect(fromArray).toEqual({});
|
|
|
|
const fromObject = buildOmoProfilePreview({}, {}, '{ "foo": "bar" }');
|
|
expect(fromObject).toEqual({ foo: "bar" });
|
|
});
|
|
});
|
|
|
|
describe("buildOmoSlimProfilePreview", () => {
|
|
it("保留 top-level council 配置,同时写入 council agent 模型", () => {
|
|
const preview = buildOmoSlimProfilePreview(
|
|
{
|
|
council: { model: "openai/gpt-5.4-mini" },
|
|
},
|
|
'{ "council": { "default_preset": "default" }, "fallback": { "enabled": true } }',
|
|
);
|
|
|
|
expect(preview).toEqual({
|
|
council: { default_preset: "default" },
|
|
fallback: { enabled: true },
|
|
agents: {
|
|
council: { model: "openai/gpt-5.4-mini" },
|
|
},
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("OMO Slim metadata", () => {
|
|
it("将 council 视为内置且可禁用的 agent", () => {
|
|
expect(OMO_SLIM_BUILTIN_AGENTS).toContainEqual(
|
|
expect.objectContaining({
|
|
key: "council",
|
|
display: "Council",
|
|
group: "sub",
|
|
}),
|
|
);
|
|
expect(OMO_SLIM_DISABLEABLE_AGENTS).toContainEqual({
|
|
value: "council",
|
|
label: "Council",
|
|
});
|
|
});
|
|
});
|