


























@@ -1,5 +1,8 @@
11import { afterAll, describe, expect, it } from "vitest";
2-import { applyPluginAutoEnable } from "./plugin-auto-enable.js";
2+import {
3+applyPluginAutoEnable,
4+materializePluginAutoEnableCandidates,
5+} from "./plugin-auto-enable.js";
36import {
47makeIsolatedEnv,
58makeRegistry,
@@ -26,12 +29,19 @@ describe("applyPluginAutoEnable providers", () => {
2629},
2730},
2831 env,
32+manifestRegistry: makeRegistry([
33+{
34+id: "google",
35+channels: [],
36+autoEnableWhenConfiguredProviders: ["google-gemini-cli"],
37+},
38+]),
2939});
30403141expect(result.config.plugins?.entries?.google?.enabled).toBe(true);
3242});
334334-it("auto-enables bundled provider plugins when plugin-owned web search config exists", () => {
44+it("auto-enables provider plugins when plugin-owned web search config exists", () => {
3545const result = applyPluginAutoEnable({
3646config: {
3747plugins: {
@@ -47,14 +57,24 @@ describe("applyPluginAutoEnable providers", () => {
4757},
4858},
4959 env,
60+manifestRegistry: makeRegistry([
61+{
62+id: "xai",
63+channels: [],
64+providers: ["xai"],
65+contracts: {
66+webSearchProviders: ["grok"],
67+},
68+},
69+]),
5070});
51715272expect(result.config.plugins?.entries?.xai?.enabled).toBe(true);
5373expect(result.changes).toContain("xai web search configured, enabled automatically.");
5474});
557556-it("auto-enables xai when the plugin-owned x_search tool is configured", () => {
57-const result = applyPluginAutoEnable({
76+it("materializes xai setup auto-enable when the plugin-owned x_search tool is configured", () => {
77+const result = materializePluginAutoEnableCandidates({
5878config: {
5979plugins: {
6080entries: {
@@ -68,15 +88,23 @@ describe("applyPluginAutoEnable providers", () => {
6888},
6989},
7090},
91+candidates: [
92+{
93+pluginId: "xai",
94+kind: "setup-auto-enable",
95+reason: "xai tool configured",
96+},
97+],
7198 env,
99+manifestRegistry: makeRegistry([{ id: "xai", channels: [] }]),
72100});
7310174102expect(result.config.plugins?.entries?.xai?.enabled).toBe(true);
75103expect(result.changes).toContain("xai tool configured, enabled automatically.");
76104});
7710578-it("auto-enables xai when the plugin-owned codeExecution config is configured", () => {
79-const result = applyPluginAutoEnable({
106+it("materializes xai setup auto-enable when the plugin-owned codeExecution config is configured", () => {
107+const result = materializePluginAutoEnableCandidates({
80108config: {
81109plugins: {
82110entries: {
@@ -91,7 +119,15 @@ describe("applyPluginAutoEnable providers", () => {
91119},
92120},
93121},
122+candidates: [
123+{
124+pluginId: "xai",
125+kind: "setup-auto-enable",
126+reason: "xai tool configured",
127+},
128+],
94129 env,
130+manifestRegistry: makeRegistry([{ id: "xai", channels: [] }]),
95131});
9613297133expect(result.config.plugins?.entries?.xai?.enabled).toBe(true);
@@ -111,6 +147,13 @@ describe("applyPluginAutoEnable providers", () => {
111147},
112148},
113149 env,
150+manifestRegistry: makeRegistry([
151+{
152+id: "minimax",
153+channels: [],
154+autoEnableWhenConfiguredProviders: ["minimax-portal"],
155+},
156+]),
114157});
115158116159expect(result.config.plugins?.entries?.minimax?.enabled).toBe(true);
@@ -130,6 +173,13 @@ describe("applyPluginAutoEnable providers", () => {
130173},
131174},
132175 env,
176+manifestRegistry: makeRegistry([
177+{
178+id: "minimax",
179+channels: [],
180+autoEnableWhenConfiguredProviders: ["minimax"],
181+},
182+]),
133183});
134184135185expect(result.config.plugins?.entries?.minimax?.enabled).toBe(true);
@@ -148,6 +198,7 @@ describe("applyPluginAutoEnable providers", () => {
148198},
149199},
150200 env,
201+manifestRegistry: makeRegistry([]),
151202});
152203153204expect(result.config.plugins?.entries?.openai).toBeUndefined();
@@ -249,31 +300,40 @@ describe("applyPluginAutoEnable providers", () => {
249300expect(result.changes).toContain("acme tool configured, enabled automatically.");
250301});
251302252-it("auto-enables acpx plugin when ACP is configured", () => {
253-const result = applyPluginAutoEnable({
303+it("materializes acpx setup auto-enable when ACP is configured", () => {
304+const result = materializePluginAutoEnableCandidates({
254305config: {
255306acp: {
256307enabled: true,
257308},
258309},
310+candidates: [
311+{
312+pluginId: "acpx",
313+kind: "setup-auto-enable",
314+reason: "ACP runtime configured",
315+},
316+],
259317 env,
260318});
261319262320expect(result.config.plugins?.entries?.acpx?.enabled).toBe(true);
263321expect(result.changes.join("\n")).toContain("ACP runtime configured, enabled automatically.");
264322});
265323266-it("does not auto-enable acpx when a different ACP backend is configured", () => {
267-const result = applyPluginAutoEnable({
324+it("does not materialize acpx when no setup auto-enable candidate is present", () => {
325+const result = materializePluginAutoEnableCandidates({
268326config: {
269327acp: {
270328enabled: true,
271329backend: "custom-runtime",
272330},
273331},
332+candidates: [],
274333 env,
275334});
276335277336expect(result.config.plugins?.entries?.acpx?.enabled).toBeUndefined();
337+expect(result.changes).toEqual([]);
278338});
279339});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。