Compare commits

...

3 Commits

Author SHA1 Message Date
Abhijit Balaji b8eb13ea1f test: fix missing getAllowedTools mock in gemini.tsx tests 2026-02-06 16:07:44 -08:00
Abhijit Balaji ba48dd04b4 fix: Use coreEvents.emitFeedback directly for deprecation warning
Removes the unnecessary setTimeout wrapper when emitting the allowedTools
deprecation warning, leveraging the built-in event backlog mechanism of
CoreEventEmitter.
2026-02-06 16:01:56 -08:00
Abhijit Balaji 4731df1fe6 feat: Deprecate tool args in favor of policy engine
Deprecate `--allowedTools`, `--excludeTools`, and `--coreTools` in favor of the Policy Engine.
Display a warning when `allowed-tools` CLI argument is used.

Fixes #11302
2026-02-06 16:01:55 -08:00
5 changed files with 17 additions and 1 deletions
+2 -1
View File
@@ -177,7 +177,8 @@ export async function parseArguments(
type: 'array',
string: true,
nargs: 1,
description: 'Tools that are allowed to run without confirmation',
description:
'[DEPRECATED: Use Policy Engine instead See https://geminicli.com/docs/core/policy-engine] Tools that are allowed to run without confirmation.',
coerce: (tools: string[]) =>
// Handle comma-separated values
tools.flatMap((tool) => tool.split(',').map((t) => t.trim())),
+2
View File
@@ -538,6 +538,7 @@ describe('gemini.tsx main function kitty protocol', () => {
const mockConfig = createMockConfig({
isInteractive: () => false,
getAllowedTools: vi.fn(),
getQuestion: () => '',
getSandbox: () => undefined,
getListExtensions: () => flag === 'listExtensions',
@@ -614,6 +615,7 @@ describe('gemini.tsx main function kitty protocol', () => {
const mockConfig = createMockConfig({
isInteractive: () => false,
getAllowedTools: vi.fn(),
getQuestion: () => '',
getSandbox: () => ({ command: 'docker', image: 'test-image' }),
});
+8
View File
@@ -518,6 +518,14 @@ export async function main() {
adminControlsListner.setConfig(config);
// Show deprecation warning only for allowedTools as that's the only one set by the user currently via command line args
if (config.getAllowedTools() !== undefined) {
coreEvents.emitFeedback(
'warning',
`The allowed-tools cli argument is deprecated and will be removed in Gemini CLI 1.0: Please use the Policy Engine to manage tool permissions instead: https://geminicli.com/docs/core/policy-engine/`,
);
}
if (config.isInteractive() && config.storage && config.getDebugMode()) {
const { registerActivityLogger } = await import(
'./utils/activityLogger.js'
+2
View File
@@ -78,6 +78,7 @@ vi.mock('./config/config.js', () => ({
getQuestion: vi.fn(() => ''),
isInteractive: () => false,
storage: { initialize: vi.fn().mockResolvedValue(undefined) },
getAllowedTools: vi.fn(),
} as unknown as Config),
parseArguments: vi.fn().mockResolvedValue({}),
isDebugMode: vi.fn(() => false),
@@ -188,6 +189,7 @@ describe('gemini.tsx main function cleanup', () => {
} as any); // eslint-disable-line @typescript-eslint/no-explicit-any
vi.mocked(loadCliConfig).mockResolvedValue({
isInteractive: vi.fn(() => false),
getAllowedTools: vi.fn(),
getQuestion: vi.fn(() => 'test'),
getSandbox: vi.fn(() => false),
getDebugMode: vi.fn(() => false),
+3
View File
@@ -376,8 +376,11 @@ export interface ConfigParameters {
debugMode: boolean;
question?: string;
/** @deprecated Use the Policy System instead. See https://geminicli.com/docs/core/policy-engine/ */
coreTools?: string[];
/** @deprecated Use the Policy System instead. See https://geminicli.com/docs/core/policy-engine/ */
allowedTools?: string[];
/** @deprecated Use the Policy System instead. See https://geminicli.com/docs/core/policy-engine/ */
excludeTools?: string[];
toolDiscoveryCommand?: string;
toolCallCommand?: string;