Skip to content

Commit c9e1265

Browse files
authored
Fix backwards-compatibility for allowedTools -> tools.allowed (google-gemini#7384)
1 parent 2a0e69d commit c9e1265

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

packages/cli/src/config/settings.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,27 @@ describe('Settings Loading and Merging', () => {
543543
});
544544
});
545545

546+
it('should rewrite allowedTools to tools.allowed during migration', () => {
547+
(mockFsExistsSync as Mock).mockImplementation(
548+
(p: fs.PathLike) => p === USER_SETTINGS_PATH,
549+
);
550+
const legacySettingsContent = {
551+
allowedTools: ['fs', 'shell'],
552+
};
553+
(fs.readFileSync as Mock).mockImplementation(
554+
(p: fs.PathOrFileDescriptor) => {
555+
if (p === USER_SETTINGS_PATH)
556+
return JSON.stringify(legacySettingsContent);
557+
return '{}';
558+
},
559+
);
560+
561+
const settings = loadSettings(MOCK_WORKSPACE_DIR);
562+
563+
expect(settings.merged.tools?.allowed).toEqual(['fs', 'shell']);
564+
expect((settings.merged as TestSettings)['allowedTools']).toBeUndefined();
565+
});
566+
546567
it('should correctly merge and migrate legacy array properties from multiple scopes', () => {
547568
(mockFsExistsSync as Mock).mockReturnValue(true);
548569
const legacyUserSettings = {

packages/cli/src/config/settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const MIGRATION_MAP: Record<string, string> = {
6464
fileFiltering: 'context.fileFiltering',
6565
sandbox: 'tools.sandbox',
6666
shouldUseNodePtyShell: 'tools.usePty',
67+
allowedTools: 'tools.allowed',
6768
coreTools: 'tools.core',
6869
excludeTools: 'tools.exclude',
6970
toolDiscoveryCommand: 'tools.discoveryCommand',

0 commit comments

Comments
 (0)