feat(core): Remove legacy settings. (#17244)

This commit is contained in:
joshualitt
2026-01-22 12:59:47 -08:00
committed by GitHub
parent 2ac7900d95
commit 62dd9b5b3c
15 changed files with 321 additions and 390 deletions

View File

@@ -764,9 +764,6 @@ export async function loadCliConfig(
output: {
format: (argv.outputFormat ?? settings.output?.format) as OutputFormat,
},
codebaseInvestigatorSettings:
settings.experimental?.codebaseInvestigatorSettings,
cliHelpAgentSettings: settings.experimental?.cliHelpAgentSettings,
fakeResponses: argv.fakeResponses,
recordResponses: argv.recordResponses,
retryFetchErrors: settings.general?.retryFetchErrors,

View File

@@ -2012,6 +2012,56 @@ describe('Settings Loading and Merging', () => {
// Merged should also reflect it (system overrides defaults, but both are migrated)
expect(settings.merged.general?.enableAutoUpdateNotification).toBe(false);
});
it('should migrate experimental agent settings to agents overrides', () => {
const userSettingsContent = {
experimental: {
codebaseInvestigatorSettings: {
enabled: true,
maxNumTurns: 15,
maxTimeMinutes: 5,
thinkingBudget: 16384,
model: 'gemini-1.5-pro',
},
cliHelpAgentSettings: {
enabled: false,
},
},
};
vi.mocked(fs.existsSync).mockReturnValue(true);
(fs.readFileSync as Mock).mockImplementation(
(p: fs.PathOrFileDescriptor) => {
if (p === USER_SETTINGS_PATH)
return JSON.stringify(userSettingsContent);
return '{}';
},
);
const settings = loadSettings(MOCK_WORKSPACE_DIR);
// Verify migration to agents.overrides
expect(settings.user.settings.agents?.overrides).toMatchObject({
codebase_investigator: {
enabled: true,
runConfig: {
maxTurns: 15,
maxTimeMinutes: 5,
},
modelConfig: {
model: 'gemini-1.5-pro',
generateContentConfig: {
thinkingConfig: {
thinkingBudget: 16384,
},
},
},
},
cli_help: {
enabled: false,
},
});
});
});
describe('saveSettings', () => {

View File

@@ -804,6 +804,14 @@ export function migrateDeprecatedSettings(
anyModified = true;
}
}
// Migrate experimental agent settings
anyModified ||= migrateExperimentalSettings(
settings,
loadedSettings,
scope,
removeDeprecated,
);
};
processScope(SettingScope.User);
@@ -852,3 +860,100 @@ export function saveModelChange(
);
}
}
function migrateExperimentalSettings(
settings: Settings,
loadedSettings: LoadedSettings,
scope: LoadableSettingScope,
removeDeprecated: boolean,
): boolean {
const experimentalSettings = settings.experimental as
| Record<string, unknown>
| undefined;
if (experimentalSettings) {
const agentsSettings = {
...(settings.agents as Record<string, unknown> | undefined),
};
const agentsOverrides = {
...((agentsSettings['overrides'] as Record<string, unknown>) || {}),
};
let modified = false;
// Migrate codebaseInvestigatorSettings -> agents.overrides.codebase_investigator
if (experimentalSettings['codebaseInvestigatorSettings']) {
const old = experimentalSettings[
'codebaseInvestigatorSettings'
] as Record<string, unknown>;
const override = {
...(agentsOverrides['codebase_investigator'] as
| Record<string, unknown>
| undefined),
};
if (old['enabled'] !== undefined) override['enabled'] = old['enabled'];
const runConfig = {
...(override['runConfig'] as Record<string, unknown> | undefined),
};
if (old['maxNumTurns'] !== undefined)
runConfig['maxTurns'] = old['maxNumTurns'];
if (old['maxTimeMinutes'] !== undefined)
runConfig['maxTimeMinutes'] = old['maxTimeMinutes'];
if (Object.keys(runConfig).length > 0) override['runConfig'] = runConfig;
if (old['model'] !== undefined || old['thinkingBudget'] !== undefined) {
const modelConfig = {
...(override['modelConfig'] as Record<string, unknown> | undefined),
};
if (old['model'] !== undefined) modelConfig['model'] = old['model'];
if (old['thinkingBudget'] !== undefined) {
const generateContentConfig = {
...(modelConfig['generateContentConfig'] as
| Record<string, unknown>
| undefined),
};
const thinkingConfig = {
...(generateContentConfig['thinkingConfig'] as
| Record<string, unknown>
| undefined),
};
thinkingConfig['thinkingBudget'] = old['thinkingBudget'];
generateContentConfig['thinkingConfig'] = thinkingConfig;
modelConfig['generateContentConfig'] = generateContentConfig;
}
override['modelConfig'] = modelConfig;
}
agentsOverrides['codebase_investigator'] = override;
modified = true;
}
// Migrate cliHelpAgentSettings -> agents.overrides.cli_help
if (experimentalSettings['cliHelpAgentSettings']) {
const old = experimentalSettings['cliHelpAgentSettings'] as Record<
string,
unknown
>;
const override = {
...(agentsOverrides['cli_help'] as Record<string, unknown> | undefined),
};
if (old['enabled'] !== undefined) override['enabled'] = old['enabled'];
agentsOverrides['cli_help'] = override;
modified = true;
}
if (modified) {
agentsSettings['overrides'] = agentsOverrides;
loadedSettings.setValue(scope, 'agents', agentsSettings);
if (removeDeprecated) {
const newExperimental = { ...experimentalSettings };
delete newExperimental['codebaseInvestigatorSettings'];
delete newExperimental['cliHelpAgentSettings'];
loadedSettings.setValue(scope, 'experimental', newExperimental);
}
return true;
}
}
return false;
}

View File

@@ -20,7 +20,6 @@ import {
DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
DEFAULT_MODEL_CONFIGS,
GEMINI_MODEL_ALIAS_AUTO,
} from '@google/gemini-cli-core';
import type { CustomTheme } from '../ui/themes/theme.js';
import type { SessionRetentionSettings } from './settings.js';
@@ -1461,66 +1460,6 @@ const SETTINGS_SCHEMA = {
description: 'Enable Agent Skills (experimental).',
showInDialog: true,
},
codebaseInvestigatorSettings: {
type: 'object',
label: 'Codebase Investigator Settings',
category: 'Experimental',
requiresRestart: true,
default: {},
description: 'Configuration for Codebase Investigator.',
showInDialog: false,
properties: {
enabled: {
type: 'boolean',
label: 'Enable Codebase Investigator',
category: 'Experimental',
requiresRestart: true,
default: true,
description: 'Enable the Codebase Investigator agent.',
showInDialog: true,
},
maxNumTurns: {
type: 'number',
label: 'Codebase Investigator Max Num Turns',
category: 'Experimental',
requiresRestart: true,
default: 10,
description:
'Maximum number of turns for the Codebase Investigator agent.',
showInDialog: true,
},
maxTimeMinutes: {
type: 'number',
label: 'Max Time (Minutes)',
category: 'Experimental',
requiresRestart: true,
default: 3,
description:
'Maximum time for the Codebase Investigator agent (in minutes).',
showInDialog: false,
},
thinkingBudget: {
type: 'number',
label: 'Thinking Budget',
category: 'Experimental',
requiresRestart: true,
default: 8192,
description:
'The thinking budget for the Codebase Investigator agent.',
showInDialog: false,
},
model: {
type: 'string',
label: 'Model',
category: 'Experimental',
requiresRestart: true,
default: GEMINI_MODEL_ALIAS_AUTO,
description:
'The model to use for the Codebase Investigator agent.',
showInDialog: false,
},
},
},
useOSC52Paste: {
type: 'boolean',
label: 'Use OSC 52 Paste',
@@ -1531,26 +1470,6 @@ const SETTINGS_SCHEMA = {
'Use OSC 52 sequence for pasting instead of clipboardy (useful for remote sessions).',
showInDialog: true,
},
cliHelpAgentSettings: {
type: 'object',
label: 'CLI Help Agent Settings',
category: 'Experimental',
requiresRestart: true,
default: {},
description: 'Configuration for CLI Help Agent.',
showInDialog: false,
properties: {
enabled: {
type: 'boolean',
label: 'Enable CLI Help Agent',
category: 'Experimental',
requiresRestart: true,
default: true,
description: 'Enable the CLI Help Agent.',
showInDialog: true,
},
},
},
plan: {
type: 'boolean',
label: 'Plan',

View File

@@ -155,8 +155,12 @@ describe('Settings Repro', () => {
experimental: {
useModelRouter: false,
enableSubagents: false,
codebaseInvestigatorSettings: {
enabled: true,
},
agents: {
overrides: {
codebase_investigator: {
enabled: true,
},
},
},
ui: {