mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 13:22:35 -07:00
feat(core): experimental in-progress steering hints (1 of 3) (#19008)
This commit is contained in:
@@ -41,6 +41,7 @@ import type { SkillDefinition } from '../skills/skillLoader.js';
|
||||
import type { McpClientManager } from '../tools/mcp-client-manager.js';
|
||||
import { DEFAULT_MODEL_CONFIGS } from './defaultModelConfigs.js';
|
||||
import { DEFAULT_GEMINI_MODEL } from './models.js';
|
||||
import { Storage } from './storage.js';
|
||||
|
||||
vi.mock('fs', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('fs')>();
|
||||
@@ -279,16 +280,21 @@ describe('Server Config (config.ts)', () => {
|
||||
await expect(config.initialize()).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('should throw an error if initialized more than once', async () => {
|
||||
it('should deduplicate multiple calls to initialize', async () => {
|
||||
const config = new Config({
|
||||
...baseParams,
|
||||
checkpointing: false,
|
||||
});
|
||||
|
||||
await expect(config.initialize()).resolves.toBeUndefined();
|
||||
await expect(config.initialize()).rejects.toThrow(
|
||||
'Config was already initialized',
|
||||
);
|
||||
const storageSpy = vi.spyOn(Storage.prototype, 'initialize');
|
||||
|
||||
await Promise.all([
|
||||
config.initialize(),
|
||||
config.initialize(),
|
||||
config.initialize(),
|
||||
]);
|
||||
|
||||
expect(storageSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should await MCP initialization in non-interactive mode', async () => {
|
||||
|
||||
@@ -621,7 +621,8 @@ export class Config {
|
||||
private readonly enablePromptCompletion: boolean = false;
|
||||
private readonly truncateToolOutputThreshold: number;
|
||||
private compressionTruncationCounter = 0;
|
||||
private initialized: boolean = false;
|
||||
private initialized = false;
|
||||
private initPromise: Promise<void> | undefined;
|
||||
readonly storage: Storage;
|
||||
private readonly fileExclusions: FileExclusions;
|
||||
private readonly eventEmitter?: EventEmitter;
|
||||
@@ -674,7 +675,6 @@ export class Config {
|
||||
private remoteAdminSettings: AdminControlsSettings | undefined;
|
||||
private latestApiRequest: GenerateContentParameters | undefined;
|
||||
private lastModeSwitchTime: number = Date.now();
|
||||
|
||||
private approvedPlanPath: string | undefined;
|
||||
|
||||
constructor(params: ConfigParameters) {
|
||||
@@ -917,14 +917,20 @@ export class Config {
|
||||
}
|
||||
|
||||
/**
|
||||
* Must only be called once, throws if called again.
|
||||
* Dedups initialization requests using a shared promise that is only resolved
|
||||
* once.
|
||||
*/
|
||||
async initialize(): Promise<void> {
|
||||
if (this.initialized) {
|
||||
throw Error('Config was already initialized');
|
||||
if (this.initPromise) {
|
||||
return this.initPromise;
|
||||
}
|
||||
this.initialized = true;
|
||||
|
||||
this.initPromise = this._initialize();
|
||||
|
||||
return this.initPromise;
|
||||
}
|
||||
|
||||
private async _initialize(): Promise<void> {
|
||||
await this.storage.initialize();
|
||||
|
||||
// Add pending directories to workspace context
|
||||
@@ -1011,6 +1017,7 @@ export class Config {
|
||||
|
||||
await this.geminiClient.initialize();
|
||||
this.syncPlanModeTools();
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
getContentGenerator(): ContentGenerator {
|
||||
|
||||
@@ -127,6 +127,19 @@ export const DEFAULT_MODEL_CONFIGS: ModelConfigServiceConfig = {
|
||||
},
|
||||
},
|
||||
},
|
||||
'fast-ack-helper': {
|
||||
extends: 'base',
|
||||
modelConfig: {
|
||||
model: 'gemini-2.5-flash-lite',
|
||||
generateContentConfig: {
|
||||
temperature: 0.2,
|
||||
maxOutputTokens: 120,
|
||||
thinkingConfig: {
|
||||
thinkingBudget: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
'edit-corrector': {
|
||||
extends: 'base',
|
||||
modelConfig: {
|
||||
|
||||
Reference in New Issue
Block a user