From eb25ab638940a3959c3e4aa05af34d63c007fb4e Mon Sep 17 00:00:00 2001 From: Aidan Cunniffe Date: Sat, 21 Mar 2026 12:29:06 -0400 Subject: [PATCH] rename checkpoint to gitAIBefore/AfterEdit --- src/core/tools/ApplyDiffTool.ts | 10 ++++---- src/core/tools/ApplyPatchTool.ts | 16 ++++++------- src/core/tools/EditFileTool.ts | 6 ++--- src/core/tools/EditTool.ts | 6 ++--- src/core/tools/SearchReplaceTool.ts | 6 ++--- src/core/tools/WriteToFileTool.ts | 22 ++++++++--------- src/services/git-ai/__tests__/index.spec.ts | 26 ++++++++++----------- src/services/git-ai/index.ts | 10 ++++---- 8 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/core/tools/ApplyDiffTool.ts b/src/core/tools/ApplyDiffTool.ts index fe11aa806d..f519524b54 100644 --- a/src/core/tools/ApplyDiffTool.ts +++ b/src/core/tools/ApplyDiffTool.ts @@ -14,7 +14,7 @@ import { EXPERIMENT_IDS, experiments } from "../../shared/experiments" import { computeDiffStats, sanitizeUnifiedDiff } from "../diff/stats" import type { ToolUse } from "../../shared/tools" -import { checkpointBeforeEdit, checkpointAfterEdit } from "../../services/git-ai" +import { gitAiBeforeEdit, gitAiAfterEdit } from "../../services/git-ai" import { BaseTool, ToolCallbacks } from "./BaseTool" @@ -178,7 +178,7 @@ export class ApplyDiffTool extends BaseTool<"apply_diff"> { // Save directly without showing diff view or opening the file task.diffViewProvider.editType = "modify" task.diffViewProvider.originalContent = originalContent - await checkpointBeforeEdit(task.cwd, [relPath]) + await gitAiBeforeEdit(task.cwd, [relPath]) await task.diffViewProvider.saveDirectly( relPath, diffResult.content, @@ -186,10 +186,10 @@ export class ApplyDiffTool extends BaseTool<"apply_diff"> { diagnosticsEnabled, writeDelayMs, ) - await checkpointAfterEdit(task.cwd, task, [relPath]) + await gitAiAfterEdit(task.cwd, task, [relPath]) } else { // Original behavior with diff view - await checkpointBeforeEdit(task.cwd, [relPath]) + await gitAiBeforeEdit(task.cwd, [relPath]) // Show diff view before asking for approval task.diffViewProvider.editType = "modify" @@ -228,7 +228,7 @@ export class ApplyDiffTool extends BaseTool<"apply_diff"> { // Call saveChanges to update the DiffViewProvider properties await task.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs) - await checkpointAfterEdit(task.cwd, task, [relPath]) + await gitAiAfterEdit(task.cwd, task, [relPath]) } // Track file edit operation diff --git a/src/core/tools/ApplyPatchTool.ts b/src/core/tools/ApplyPatchTool.ts index c847bd6ae2..3589df36b2 100644 --- a/src/core/tools/ApplyPatchTool.ts +++ b/src/core/tools/ApplyPatchTool.ts @@ -11,7 +11,7 @@ import { RecordSource } from "../context-tracking/FileContextTrackerTypes" import { fileExistsAtPath } from "../../utils/fs" import { EXPERIMENT_IDS, experiments } from "../../shared/experiments" import { sanitizeUnifiedDiff, computeDiffStats } from "../diff/stats" -import { checkpointBeforeEdit, checkpointAfterEdit } from "../../services/git-ai" +import { gitAiBeforeEdit, gitAiAfterEdit } from "../../services/git-ai" import { BaseTool, ToolCallbacks } from "./BaseTool" import type { ToolUse } from "../../shared/tools" @@ -197,7 +197,7 @@ export class ApplyPatchTool extends BaseTool<"apply_patch"> { diffStats, } satisfies ClineSayTool) - await checkpointBeforeEdit(task.cwd, [relPath]) + await gitAiBeforeEdit(task.cwd, [relPath]) // Show diff view if focus disruption prevention is disabled if (!isPreventFocusDisruptionEnabled) { @@ -223,7 +223,7 @@ export class ApplyPatchTool extends BaseTool<"apply_patch"> { } else { await task.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs) } - await checkpointAfterEdit(task.cwd, task, [relPath]) + await gitAiAfterEdit(task.cwd, task, [relPath]) // Track file edit operation await task.fileContextTracker.trackFileContext(relPath, "roo_edited" as RecordSource) @@ -278,7 +278,7 @@ export class ApplyPatchTool extends BaseTool<"apply_patch"> { } // Delete the file - await checkpointBeforeEdit(task.cwd, [relPath]) + await gitAiBeforeEdit(task.cwd, [relPath]) try { await fs.unlink(absolutePath) } catch (error) { @@ -287,7 +287,7 @@ export class ApplyPatchTool extends BaseTool<"apply_patch"> { pushToolResult(formatResponse.toolError(errorMessage)) return } - await checkpointAfterEdit(task.cwd, task, [relPath]) + await gitAiAfterEdit(task.cwd, task, [relPath]) task.didEditFile = true pushToolResult(`Successfully deleted ${relPath}`) @@ -359,7 +359,7 @@ export class ApplyPatchTool extends BaseTool<"apply_patch"> { diffStats, } satisfies ClineSayTool) - await checkpointBeforeEdit(task.cwd, [relPath]) + await gitAiBeforeEdit(task.cwd, [relPath]) // Show diff view if focus disruption prevention is disabled if (!isPreventFocusDisruptionEnabled) { @@ -438,7 +438,7 @@ export class ApplyPatchTool extends BaseTool<"apply_patch"> { } catch (error) { console.error(`Failed to delete original file after move: ${error}`) } - await checkpointAfterEdit(task.cwd, task, [relPath, change.movePath]) + await gitAiAfterEdit(task.cwd, task, [relPath, change.movePath]) await task.fileContextTracker.trackFileContext(change.movePath, "roo_edited" as RecordSource) } else { @@ -448,7 +448,7 @@ export class ApplyPatchTool extends BaseTool<"apply_patch"> { } else { await task.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs) } - await checkpointAfterEdit(task.cwd, task, [relPath]) + await gitAiAfterEdit(task.cwd, task, [relPath]) await task.fileContextTracker.trackFileContext(relPath, "roo_edited" as RecordSource) } diff --git a/src/core/tools/EditFileTool.ts b/src/core/tools/EditFileTool.ts index fbf946119d..52dcea3278 100644 --- a/src/core/tools/EditFileTool.ts +++ b/src/core/tools/EditFileTool.ts @@ -13,7 +13,7 @@ import { EXPERIMENT_IDS, experiments } from "../../shared/experiments" import { sanitizeUnifiedDiff, computeDiffStats } from "../diff/stats" import type { ToolUse } from "../../shared/tools" -import { checkpointBeforeEdit, checkpointAfterEdit } from "../../services/git-ai" +import { gitAiBeforeEdit, gitAiAfterEdit } from "../../services/git-ai" import { BaseTool, ToolCallbacks } from "./BaseTool" @@ -417,7 +417,7 @@ export class EditFileTool extends BaseTool<"edit_file"> { diffStats, } satisfies ClineSayTool) - await checkpointBeforeEdit(task.cwd, [relPath]) + await gitAiBeforeEdit(task.cwd, [relPath]) // Show diff view if focus disruption prevention is disabled if (!isPreventFocusDisruptionEnabled) { @@ -452,7 +452,7 @@ export class EditFileTool extends BaseTool<"edit_file"> { // Call saveChanges to update the DiffViewProvider properties await task.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs) } - await checkpointAfterEdit(task.cwd, task, [relPath]) + await gitAiAfterEdit(task.cwd, task, [relPath]) // Track file edit operation if (relPath) { diff --git a/src/core/tools/EditTool.ts b/src/core/tools/EditTool.ts index c91ed727d9..f6b65fb5f9 100644 --- a/src/core/tools/EditTool.ts +++ b/src/core/tools/EditTool.ts @@ -13,7 +13,7 @@ import { EXPERIMENT_IDS, experiments } from "../../shared/experiments" import { sanitizeUnifiedDiff, computeDiffStats } from "../diff/stats" import type { ToolUse } from "../../shared/tools" -import { checkpointBeforeEdit, checkpointAfterEdit } from "../../services/git-ai" +import { gitAiBeforeEdit, gitAiAfterEdit } from "../../services/git-ai" import { BaseTool, ToolCallbacks } from "./BaseTool" @@ -192,7 +192,7 @@ export class EditTool extends BaseTool<"edit"> { diffStats, } satisfies ClineSayTool) - await checkpointBeforeEdit(task.cwd, [relPath]) + await gitAiBeforeEdit(task.cwd, [relPath]) // Show diff view if focus disruption prevention is disabled if (!isPreventFocusDisruptionEnabled) { @@ -221,7 +221,7 @@ export class EditTool extends BaseTool<"edit"> { // Call saveChanges to update the DiffViewProvider properties await task.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs) } - await checkpointAfterEdit(task.cwd, task, [relPath]) + await gitAiAfterEdit(task.cwd, task, [relPath]) // Track file edit operation if (relPath) { diff --git a/src/core/tools/SearchReplaceTool.ts b/src/core/tools/SearchReplaceTool.ts index 212f46a2e0..221021279b 100644 --- a/src/core/tools/SearchReplaceTool.ts +++ b/src/core/tools/SearchReplaceTool.ts @@ -13,7 +13,7 @@ import { EXPERIMENT_IDS, experiments } from "../../shared/experiments" import { sanitizeUnifiedDiff, computeDiffStats } from "../diff/stats" import type { ToolUse } from "../../shared/tools" -import { checkpointBeforeEdit, checkpointAfterEdit } from "../../services/git-ai" +import { gitAiBeforeEdit, gitAiAfterEdit } from "../../services/git-ai" import { BaseTool, ToolCallbacks } from "./BaseTool" @@ -188,7 +188,7 @@ export class SearchReplaceTool extends BaseTool<"search_replace"> { diffStats, } satisfies ClineSayTool) - await checkpointBeforeEdit(task.cwd, [relPath]) + await gitAiBeforeEdit(task.cwd, [relPath]) // Show diff view if focus disruption prevention is disabled if (!isPreventFocusDisruptionEnabled) { @@ -217,7 +217,7 @@ export class SearchReplaceTool extends BaseTool<"search_replace"> { // Call saveChanges to update the DiffViewProvider properties await task.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs) } - await checkpointAfterEdit(task.cwd, task, [relPath]) + await gitAiAfterEdit(task.cwd, task, [relPath]) // Track file edit operation if (relPath) { diff --git a/src/core/tools/WriteToFileTool.ts b/src/core/tools/WriteToFileTool.ts index 9d32b7c509..f00379883a 100644 --- a/src/core/tools/WriteToFileTool.ts +++ b/src/core/tools/WriteToFileTool.ts @@ -16,7 +16,7 @@ import { EXPERIMENT_IDS, experiments } from "../../shared/experiments" import { convertNewFileToUnifiedDiff, computeDiffStats, sanitizeUnifiedDiff } from "../diff/stats" import type { ToolUse } from "../../shared/tools" -import { checkpointBeforeEdit, checkpointAfterEdit } from "../../services/git-ai" +import { gitAiBeforeEdit, gitAiAfterEdit } from "../../services/git-ai" import { BaseTool, ToolCallbacks } from "./BaseTool" @@ -27,11 +27,11 @@ interface WriteToFileParams { export class WriteToFileTool extends BaseTool<"write_to_file"> { readonly name = "write_to_file" as const - private didCheckpointBeforeEdit = false + private didGitAiBeforeEdit = false override resetPartialState(): void { super.resetPartialState() - this.didCheckpointBeforeEdit = false + this.didGitAiBeforeEdit = false } async execute(params: WriteToFileParams, task: Task, callbacks: ToolCallbacks): Promise { @@ -141,12 +141,12 @@ export class WriteToFileTool extends BaseTool<"write_to_file"> { return } - await checkpointBeforeEdit(task.cwd, [relPath]) + await gitAiBeforeEdit(task.cwd, [relPath]) await task.diffViewProvider.saveDirectly(relPath, newContent, false, diagnosticsEnabled, writeDelayMs) - await checkpointAfterEdit(task.cwd, task, [relPath]) + await gitAiAfterEdit(task.cwd, task, [relPath]) } else { - if (!this.didCheckpointBeforeEdit) { - await checkpointBeforeEdit(task.cwd, [relPath]) + if (!this.didGitAiBeforeEdit) { + await gitAiBeforeEdit(task.cwd, [relPath]) } if (!task.diffViewProvider.isEditing) { @@ -181,7 +181,7 @@ export class WriteToFileTool extends BaseTool<"write_to_file"> { } await task.diffViewProvider.saveChanges(diagnosticsEnabled, writeDelayMs) - await checkpointAfterEdit(task.cwd, task, [relPath]) + await gitAiAfterEdit(task.cwd, task, [relPath]) } if (relPath) { @@ -261,9 +261,9 @@ export class WriteToFileTool extends BaseTool<"write_to_file"> { if (newContent) { if (!task.diffViewProvider.isEditing) { - if (!this.didCheckpointBeforeEdit) { - await checkpointBeforeEdit(task.cwd, [relPath!]) - this.didCheckpointBeforeEdit = true + if (!this.didGitAiBeforeEdit) { + await gitAiBeforeEdit(task.cwd, [relPath!]) + this.didGitAiBeforeEdit = true } await task.diffViewProvider.open(relPath!) } diff --git a/src/services/git-ai/__tests__/index.spec.ts b/src/services/git-ai/__tests__/index.spec.ts index c7e8044b94..e3a27eac31 100644 --- a/src/services/git-ai/__tests__/index.spec.ts +++ b/src/services/git-ai/__tests__/index.spec.ts @@ -6,8 +6,8 @@ import { EventEmitter } from "events" import { Writable } from "stream" import { - checkpointBeforeEdit, - checkpointAfterEdit, + gitAiBeforeEdit, + gitAiAfterEdit, isGitAiAvailable, resetGitAiCache, } from "../index" @@ -119,11 +119,11 @@ describe("git-ai service", () => { }) }) - describe("checkpointBeforeEdit", () => { + describe("gitAiBeforeEdit", () => { it("no-ops when git-ai is not installed", async () => { mockExecFailure("not found") - await checkpointBeforeEdit("/test/workspace", ["src/file.ts"]) + await gitAiBeforeEdit("/test/workspace", ["src/file.ts"]) expect(childProcess.spawn).not.toHaveBeenCalled() }) @@ -146,7 +146,7 @@ describe("git-ai service", () => { }, ) - await checkpointBeforeEdit("/not/a/repo", ["src/file.ts"]) + await gitAiBeforeEdit("/not/a/repo", ["src/file.ts"]) expect(childProcess.spawn).not.toHaveBeenCalled() }) @@ -169,7 +169,7 @@ describe("git-ai service", () => { const { proc, stdinData } = createMockProcess() ;(childProcess.spawn as any).mockReturnValue(proc) - const promise = checkpointBeforeEdit("/test/workspace", ["src/file.ts"]) + const promise = gitAiBeforeEdit("/test/workspace", ["src/file.ts"]) // Simulate successful exit setTimeout(() => proc.emit("close", 0), 10) @@ -191,12 +191,12 @@ describe("git-ai service", () => { }) }) - describe("checkpointAfterEdit", () => { + describe("gitAiAfterEdit", () => { it("no-ops when git-ai is not installed", async () => { mockExecFailure("not found") const task = createMockTask() - await checkpointAfterEdit("/test/workspace", task, ["src/file.ts"]) + await gitAiAfterEdit("/test/workspace", task, ["src/file.ts"]) expect(childProcess.spawn).not.toHaveBeenCalled() }) @@ -219,7 +219,7 @@ describe("git-ai service", () => { ;(childProcess.spawn as any).mockReturnValue(proc) const task = createMockTask() - const promise = checkpointAfterEdit("/test/workspace", task, ["src/file.ts"]) + const promise = gitAiAfterEdit("/test/workspace", task, ["src/file.ts"]) setTimeout(() => proc.emit("close", 0), 10) @@ -239,7 +239,7 @@ describe("git-ai service", () => { }) describe("error handling", () => { - it("checkpointBeforeEdit never throws", async () => { + it("gitAiBeforeEdit never throws", async () => { let callCount = 0 ;(childProcess.exec as any).mockImplementation( (_cmd: string, _opts: any, callback?: Function) => { @@ -256,7 +256,7 @@ describe("git-ai service", () => { const { proc } = createMockProcess() ;(childProcess.spawn as any).mockReturnValue(proc) - const promise = checkpointBeforeEdit("/test/workspace", ["file.ts"]) + const promise = gitAiBeforeEdit("/test/workspace", ["file.ts"]) // Simulate failure exit setTimeout(() => proc.emit("close", 1), 10) @@ -265,7 +265,7 @@ describe("git-ai service", () => { await expect(promise).resolves.toBeUndefined() }) - it("checkpointAfterEdit never throws", async () => { + it("gitAiAfterEdit never throws", async () => { let callCount = 0 ;(childProcess.exec as any).mockImplementation( (_cmd: string, _opts: any, callback?: Function) => { @@ -287,7 +287,7 @@ describe("git-ai service", () => { // Should not throw await expect( - checkpointAfterEdit("/test/workspace", task, ["file.ts"]), + gitAiAfterEdit("/test/workspace", task, ["file.ts"]), ).resolves.toBeUndefined() }) }) diff --git a/src/services/git-ai/index.ts b/src/services/git-ai/index.ts index e3d70d2f69..11708f3d35 100644 --- a/src/services/git-ai/index.ts +++ b/src/services/git-ai/index.ts @@ -8,7 +8,7 @@ import { buildTranscript } from "./transcript" const execAsync = promisify(exec) /** - * Narrow interface for the Task data needed by checkpointAfterEdit. + * Narrow interface for the Task data needed by gitAiAfterEdit. * Avoids coupling the git-ai service to the full Task class. */ export interface GitAiTaskContext { @@ -87,7 +87,7 @@ function execWithStdin(command: string, args: string[], input: string, cwd: stri * Must be awaited before the file save to correctly attribute prior changes. * Never throws — failures are logged and silently ignored. */ -export async function checkpointBeforeEdit(cwd: string, filepaths: string[]): Promise { +export async function gitAiBeforeEdit(cwd: string, filepaths: string[]): Promise { try { if (!(await isGitAiAvailable())) { return @@ -105,7 +105,7 @@ export async function checkpointBeforeEdit(cwd: string, filepaths: string[]): Pr await execWithStdin("git-ai", ["checkpoint", "agent-v1", "--hook-input", "stdin"], payload, repoRoot) } catch (error) { - console.error("[git-ai] checkpointBeforeEdit failed:", error) + console.error("[git-ai] gitAiBeforeEdit failed:", error) } } @@ -115,7 +115,7 @@ export async function checkpointBeforeEdit(cwd: string, filepaths: string[]): Pr * * Never throws — failures are logged and silently ignored. */ -export async function checkpointAfterEdit(cwd: string, task: GitAiTaskContext, filepaths: string[]): Promise { +export async function gitAiAfterEdit(cwd: string, task: GitAiTaskContext, filepaths: string[]): Promise { try { if (!(await isGitAiAvailable())) { return @@ -139,7 +139,7 @@ export async function checkpointAfterEdit(cwd: string, task: GitAiTaskContext, f await execWithStdin("git-ai", ["checkpoint", "agent-v1", "--hook-input", "stdin"], payload, repoRoot) } catch (error) { - console.error("[git-ai] checkpointAfterEdit failed:", error) + console.error("[git-ai] gitAiAfterEdit failed:", error) } }