MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / checkpointDiff

Function checkpointDiff

src/core/checkpoints/index.ts:317–392  ·  view source on GitHub ↗
(task: Task, { ts, previousCommitHash, commitHash, mode }: CheckpointDiffOptions)

Source from the content-addressed store, hash-verified

315}
316
317export async function checkpointDiff(task: Task, { ts, previousCommitHash, commitHash, mode }: CheckpointDiffOptions) {
318 const service = await getCheckpointService(task)
319
320 if (!service) {
321 return
322 }
323
324 TelemetryService.instance.captureCheckpointDiffed(task.taskId)
325
326 let fromHash: string | undefined
327 let toHash: string | undefined
328 let title: string
329
330 const checkpoints = task.clineMessages.filter(({ say }) => say === "checkpoint_saved").map(({ text }) => text!)
331
332 if (["from-init", "full"].includes(mode) && checkpoints.length < 1) {
333 vscode.window.showInformationMessage(t("common:errors.checkpoint_no_first"))
334 return
335 }
336
337 const idx = checkpoints.indexOf(commitHash)
338 switch (mode) {
339 case "checkpoint":
340 fromHash = commitHash
341 toHash = idx !== -1 && idx < checkpoints.length - 1 ? checkpoints[idx + 1] : undefined
342 title = t("common:errors.checkpoint_diff_with_next")
343 break
344 case "from-init":
345 fromHash = checkpoints[0]
346 toHash = commitHash
347 title = t("common:errors.checkpoint_diff_since_first")
348 break
349 case "to-current":
350 fromHash = commitHash
351 toHash = undefined
352 title = t("common:errors.checkpoint_diff_to_current")
353 break
354 case "full":
355 fromHash = checkpoints[0]
356 toHash = undefined
357 title = t("common:errors.checkpoint_diff_since_first")
358 break
359 }
360
361 if (!fromHash) {
362 vscode.window.showInformationMessage(t("common:errors.checkpoint_no_previous"))
363 return
364 }
365
366 try {
367 const changes = await service.getDiff({ from: fromHash, to: toHash })
368
369 if (!changes?.length) {
370 vscode.window.showInformationMessage(t("common:errors.checkpoint_no_changes"))
371 return
372 }
373
374 await vscode.commands.executeCommand(

Callers 2

checkpointDiffMethod · 0.90
checkpoint.test.tsFile · 0.90

Calls 11

tFunction · 0.90
getCheckpointServiceFunction · 0.85
executeCommandMethod · 0.80
fileMethod · 0.80
parseMethod · 0.80
fromMethod · 0.80
toStringMethod · 0.65
logMethod · 0.65
withMethod · 0.45

Tested by

no test coverage detected