From a41bb3a70a48aa563147b87836dd2fa4ec744b5a Mon Sep 17 00:00:00 2001 From: canvrno <46584286+canvrno@users.noreply.github.com> Date: Sat, 8 Mar 2025 13:44:36 -0800 Subject: [PATCH] Checkpoints documentation cleanup (#2160) * Checkpoints documentation cleanup * Update src/integrations/checkpoints/CheckpointTracker.ts Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --------- Co-authored-by: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --- .changeset/sweet-jokes-run.md | 5 +++++ .../checkpoints/CheckpointGitOperations.ts | 2 -- .../checkpoints/CheckpointTracker.ts | 19 +++++-------------- .../checkpoints/CheckpointUtils.ts | 3 +-- 4 files changed, 11 insertions(+), 18 deletions(-) create mode 100644 .changeset/sweet-jokes-run.md diff --git a/.changeset/sweet-jokes-run.md b/.changeset/sweet-jokes-run.md new file mode 100644 index 00000000..f44cc010 --- /dev/null +++ b/.changeset/sweet-jokes-run.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Checkpoints documentation cleanup diff --git a/src/integrations/checkpoints/CheckpointGitOperations.ts b/src/integrations/checkpoints/CheckpointGitOperations.ts index 13622a12..519cf5d3 100644 --- a/src/integrations/checkpoints/CheckpointGitOperations.ts +++ b/src/integrations/checkpoints/CheckpointGitOperations.ts @@ -18,7 +18,6 @@ interface CheckpointAddResult { * - Git repository initialization and configuration * - Git settings management (user, LFS, etc.) * - Worktree configuration and management - * - Task-specific branch management (creation, switching, deletion) * - Managing nested git repositories during checkpoint operations * - File staging and checkpoint creation * - Shadow git repository maintenance and cleanup @@ -89,7 +88,6 @@ export class GitOperations { const lfsPatterns = await getLfsPatterns(cwd) await writeExcludesFile(gitPath, lfsPatterns) - // Stage all files for initial commit (important so main branch is created with all files in initial commit, and branches created from it will take up less space) await this.addCheckpointFiles(git) // Initial commit only on first repo creation diff --git a/src/integrations/checkpoints/CheckpointTracker.ts b/src/integrations/checkpoints/CheckpointTracker.ts index 6138bfee..28958222 100644 --- a/src/integrations/checkpoints/CheckpointTracker.ts +++ b/src/integrations/checkpoints/CheckpointTracker.ts @@ -33,9 +33,9 @@ import { getShadowGitPath, getWorkingDirectory, hashWorkingDir } from "./Checkpo * - Handles cleanup and resource disposal * * Checkpoint Architecture: - * - Uses a branch-per-task model to consolidate shadow git repositories - * - Each task gets its own branch within a single shadow git per workspace - * - Automatically cleans up by deleting task branches when tasks are removed + * - Unique shadow git repository for each workspace + * - Workspaces are identified by name, and hashed to a unique number + * - All commits for a workspace are stored in one shadow git, under a single branch */ class CheckpointTracker { @@ -64,7 +64,7 @@ class CheckpointTracker { /** * Creates a new CheckpointTracker instance for tracking changes in a task. - * Handles initialization of the shadow git repository and branch setup. + * Handles initialization of the shadow git repository. * * @param taskId - Unique identifier for the task to track * @param globalStoragePath - the globalStorage path @@ -78,11 +78,9 @@ class CheckpointTracker { * Key operations: * - Validates git installation and settings * - Creates/initializes shadow git repository - * - Sets up task-specific branch for new checkpoints * * Configuration: * - Respects 'cline.enableCheckpoints' VS Code setting - * - Uses branch-per-task architecture for new checkpoints */ public static async create(taskId: string, globalStoragePath: string | undefined): Promise { if (!globalStoragePath) { @@ -110,7 +108,6 @@ class CheckpointTracker { const newTracker = new CheckpointTracker(globalStoragePath, taskId, workingDir, cwdHash) - // Branch-per-task structure const gitPath = await getShadowGitPath(newTracker.globalStoragePath, newTracker.taskId, newTracker.cwdHash) await newTracker.gitOperations.initShadowGit(gitPath, workingDir) @@ -128,28 +125,24 @@ class CheckpointTracker { * * Key behaviors: * - Creates commit with checkpoint files in shadow git repo - * - For new tasks, switches to task-specific branch first * - Caches the created commit hash * * Commit structure: - * - Branch-per-task: "checkpoint-{cwdHash}-{taskId}" + * - Commit message: "checkpoint-{cwdHash}-{taskId}" * - Always allows empty commits * * Dependencies: * - Requires initialized shadow git (getShadowGitPath) - * - For new checkpoints, requires task branch setup * - Uses addCheckpointFiles to stage changes using 'git add .' * - Relies on git's native exclusion handling via the exclude file * * @returns Promise The created commit hash, or undefined if: * - Shadow git access fails - * - Branch switch fails * - Staging files fails * - Commit creation fails * @throws Error if unable to: * - Access shadow git path * - Initialize simple-git - * - Switch branches * - Stage or commit files */ public async commit(): Promise { @@ -225,7 +218,6 @@ class CheckpointTracker { * * Dependencies: * - Requires initialized shadow git (getShadowGitPath) - * - For new checkpoints, requires task branch setup * - Must be called with a valid commit hash from this task's history * * @param commitHash - The hash of the checkpoint commit to reset to @@ -233,7 +225,6 @@ class CheckpointTracker { * @throws Error if unable to: * - Access shadow git path * - Initialize simple-git - * - Switch to task branch * - Reset to target commit */ public async resetHead(commitHash: string): Promise { diff --git a/src/integrations/checkpoints/CheckpointUtils.ts b/src/integrations/checkpoints/CheckpointUtils.ts index 340073d9..e5119b12 100644 --- a/src/integrations/checkpoints/CheckpointUtils.ts +++ b/src/integrations/checkpoints/CheckpointUtils.ts @@ -5,9 +5,8 @@ import os from "os" /** * Gets the path to the shadow Git repository in globalStorage. - * For new checkpoints, uses the consolidated branch-per-task structure. * - * Branch-per-task path structure: + * Checkpoints path structure: * globalStorage/ * checkpoints/ * {cwdHash}/