mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 12:54:07 -07:00
fix(core): ensure enter_plan_mode tool registration respects experimental.plan (#18587)
This commit is contained in:
@@ -2333,10 +2333,11 @@ describe('syncPlanModeTools', () => {
|
|||||||
expect(registeredTool).toBeInstanceOf(ExitPlanModeTool);
|
expect(registeredTool).toBeInstanceOf(ExitPlanModeTool);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should register EnterPlanModeTool and unregister ExitPlanModeTool when NOT in PLAN mode', async () => {
|
it('should register EnterPlanModeTool and unregister ExitPlanModeTool when NOT in PLAN mode and experimental.plan is enabled', async () => {
|
||||||
const config = new Config({
|
const config = new Config({
|
||||||
...baseParams,
|
...baseParams,
|
||||||
approvalMode: ApprovalMode.DEFAULT,
|
approvalMode: ApprovalMode.DEFAULT,
|
||||||
|
plan: true,
|
||||||
});
|
});
|
||||||
const registry = new ToolRegistry(config, config.getMessageBus());
|
const registry = new ToolRegistry(config, config.getMessageBus());
|
||||||
vi.spyOn(config, 'getToolRegistry').mockReturnValue(registry);
|
vi.spyOn(config, 'getToolRegistry').mockReturnValue(registry);
|
||||||
@@ -2360,6 +2361,27 @@ describe('syncPlanModeTools', () => {
|
|||||||
expect(registeredTool).toBeInstanceOf(EnterPlanModeTool);
|
expect(registeredTool).toBeInstanceOf(EnterPlanModeTool);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should NOT register EnterPlanModeTool when experimental.plan is disabled', async () => {
|
||||||
|
const config = new Config({
|
||||||
|
...baseParams,
|
||||||
|
approvalMode: ApprovalMode.DEFAULT,
|
||||||
|
plan: false,
|
||||||
|
});
|
||||||
|
const registry = new ToolRegistry(config, config.getMessageBus());
|
||||||
|
vi.spyOn(config, 'getToolRegistry').mockReturnValue(registry);
|
||||||
|
|
||||||
|
const registerSpy = vi.spyOn(registry, 'registerTool');
|
||||||
|
vi.spyOn(registry, 'getTool').mockReturnValue(undefined);
|
||||||
|
|
||||||
|
config.syncPlanModeTools();
|
||||||
|
|
||||||
|
const { EnterPlanModeTool } = await import('../tools/enter-plan-mode.js');
|
||||||
|
const registeredTool = registerSpy.mock.calls.find(
|
||||||
|
(call) => call[0] instanceof EnterPlanModeTool,
|
||||||
|
);
|
||||||
|
expect(registeredTool).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
it('should call geminiClient.setTools if initialized', async () => {
|
it('should call geminiClient.setTools if initialized', async () => {
|
||||||
const config = new Config(baseParams);
|
const config = new Config(baseParams);
|
||||||
const registry = new ToolRegistry(config, config.getMessageBus());
|
const registry = new ToolRegistry(config, config.getMessageBus());
|
||||||
|
|||||||
@@ -1540,8 +1540,14 @@ export class Config {
|
|||||||
if (registry.getTool(EXIT_PLAN_MODE_TOOL_NAME)) {
|
if (registry.getTool(EXIT_PLAN_MODE_TOOL_NAME)) {
|
||||||
registry.unregisterTool(EXIT_PLAN_MODE_TOOL_NAME);
|
registry.unregisterTool(EXIT_PLAN_MODE_TOOL_NAME);
|
||||||
}
|
}
|
||||||
if (!registry.getTool(ENTER_PLAN_MODE_TOOL_NAME)) {
|
if (this.planEnabled) {
|
||||||
registry.registerTool(new EnterPlanModeTool(this, this.messageBus));
|
if (!registry.getTool(ENTER_PLAN_MODE_TOOL_NAME)) {
|
||||||
|
registry.registerTool(new EnterPlanModeTool(this, this.messageBus));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (registry.getTool(ENTER_PLAN_MODE_TOOL_NAME)) {
|
||||||
|
registry.unregisterTool(ENTER_PLAN_MODE_TOOL_NAME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user