rename checkpoint to gitAIBefore/AfterEdit

This commit is contained in:
Aidan Cunniffe 2026-03-21 12:29:06 -04:00
parent 284638487e
commit eb25ab6389
8 changed files with 51 additions and 51 deletions

View file

@ -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

View file

@ -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)
}

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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<void> {
@ -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!)
}

View file

@ -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()
})
})

View file

@ -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<void> {
export async function gitAiBeforeEdit(cwd: string, filepaths: string[]): Promise<void> {
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<void> {
export async function gitAiAfterEdit(cwd: string, task: GitAiTaskContext, filepaths: string[]): Promise<void> {
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)
}
}