Restore Checkpoint Feature (#934)

This commit is contained in:
Louis Jimenez
2025-06-11 15:33:09 -04:00
committed by GitHub
parent f75c48323c
commit e0f4f428fc
19 changed files with 837 additions and 63 deletions

View File

@@ -25,6 +25,7 @@ import { WebSearchTool } from '../tools/web-search.js';
import { GeminiClient } from '../core/client.js';
import { GEMINI_CONFIG_DIR as GEMINI_DIR } from '../tools/memoryTool.js';
import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
import { GitService } from '../services/gitService.js';
import { initializeTelemetry } from '../telemetry/index.js';
export enum ApprovalMode {
@@ -80,6 +81,7 @@ export interface ConfigParameters {
fileFilteringRespectGitIgnore?: boolean;
fileFilteringAllowBuildArtifacts?: boolean;
enableModifyWithExternalEditors?: boolean;
checkpoint?: boolean;
}
export class Config {
@@ -111,6 +113,8 @@ export class Config {
private readonly fileFilteringAllowBuildArtifacts: boolean;
private readonly enableModifyWithExternalEditors: boolean;
private fileDiscoveryService: FileDiscoveryService | null = null;
private gitService: GitService | undefined = undefined;
private readonly checkpoint: boolean;
constructor(params: ConfigParameters) {
this.sessionId = params.sessionId;
@@ -142,6 +146,7 @@ export class Config {
params.fileFilteringAllowBuildArtifacts ?? false;
this.enableModifyWithExternalEditors =
params.enableModifyWithExternalEditors ?? false;
this.checkpoint = params.checkpoint ?? false;
if (params.contextFileName) {
setGeminiMdFilename(params.contextFileName);
@@ -182,6 +187,10 @@ export class Config {
return this.targetDir;
}
getProjectRoot(): string {
return this.targetDir;
}
async getToolRegistry(): Promise<ToolRegistry> {
return this.toolRegistry;
}
@@ -265,6 +274,10 @@ export class Config {
return this.geminiClient;
}
getGeminiDir(): string {
return path.join(this.targetDir, GEMINI_DIR);
}
getGeminiIgnorePatterns(): string[] {
return this.geminiIgnorePatterns;
}
@@ -281,6 +294,10 @@ export class Config {
return this.enableModifyWithExternalEditors;
}
getCheckpointEnabled(): boolean {
return this.checkpoint;
}
async getFileService(): Promise<FileDiscoveryService> {
if (!this.fileDiscoveryService) {
this.fileDiscoveryService = new FileDiscoveryService(this.targetDir);
@@ -291,6 +308,14 @@ export class Config {
}
return this.fileDiscoveryService;
}
async getGitService(): Promise<GitService> {
if (!this.gitService) {
this.gitService = new GitService(this.targetDir);
await this.gitService.initialize();
}
return this.gitService;
}
}
function findEnvFile(startDir: string): string | null {