Table of Contents

Class WorktreeManager

Namespace
JD.AI.Core.Tools
Assembly
JD.AI.Core.dll

Manages git worktree lifecycle for isolated agent sessions. Created via --worktree / -w CLI flag.

public sealed class WorktreeManager : IAsyncDisposable
Inheritance
WorktreeManager
Implements
Inherited Members

Constructors

WorktreeManager(string)

public WorktreeManager(string repoRoot)

Parameters

repoRoot string

Properties

BranchName

Branch name created for the worktree.

public string? BranchName { get; }

Property Value

string

WorktreePath

Path to the created worktree directory, or null if not yet created.

public string? WorktreePath { get; }

Property Value

string

Methods

CreateAsync(CancellationToken)

Creates a new git worktree with a unique branch name. Returns the worktree directory path.

public Task<string> CreateAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task<string>

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

MergeAndRemoveAsync(string, CancellationToken)

Merges the worktree branch into the current branch and removes the worktree.

public Task MergeAndRemoveAsync(string targetBranch = "HEAD", CancellationToken ct = default)

Parameters

targetBranch string
ct CancellationToken

Returns

Task

RemoveAsync(CancellationToken)

Removes the worktree and deletes the branch.

public Task RemoveAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task