Skip to content
Color theme

API: @loopstack/git

Classes

GitAddTool

Tool that stages files for the next git commit.

import { GitAddTool } from '@loopstack/git';

Provided by: GitModule

export class GitAddTool extends BaseTool<GitAddArgs, object, GitAddResult> {
constructor(env: EnvironmentService, remote: RemoteClient);
protected handle(args: GitAddArgs): Promise<ToolEnvelope<GitAddResult>>;
}

GitBranchTool

Tool that lists all local git branches and indicates the current branch.

import { GitBranchTool } from '@loopstack/git';

Provided by: GitModule

export class GitBranchTool extends BaseTool<object, object, GitBranchResult> {
constructor(env: EnvironmentService, remote: RemoteClient);
protected handle(): Promise<ToolEnvelope<GitBranchResult>>;
}

GitCheckoutTool

Tool that switches to a different git branch, optionally creating it.

import { GitCheckoutTool } from '@loopstack/git';

Provided by: GitModule

export class GitCheckoutTool extends BaseTool<GitCheckoutArgs, object, GitCheckoutResult> {
constructor(env: EnvironmentService, remote: RemoteClient);
protected handle(args: GitCheckoutArgs): Promise<ToolEnvelope<GitCheckoutResult>>;
}

GitCommitTool

Tool that creates a git commit from the currently staged changes.

import { GitCommitTool } from '@loopstack/git';

Provided by: GitModule

export class GitCommitTool extends BaseTool<GitCommitArgs, object, GitCommitResult> {
constructor(env: EnvironmentService, remote: RemoteClient);
protected handle(args: GitCommitArgs): Promise<ToolEnvelope<GitCommitResult>>;
}

GitConfigUserTool

Tool that configures git user.name and user.email for the workspace repository.

import { GitConfigUserTool } from '@loopstack/git';

Provided by: GitModule

export class GitConfigUserTool extends BaseTool<GitConfigUserArgs, object, GitConfigUserResult> {
constructor(env: EnvironmentService, remote: RemoteClient);
protected handle(args: GitConfigUserArgs): Promise<ToolEnvelope<GitConfigUserResult>>;
}

GitDiffTool

Tool that lists changed files in the workspace with their change status.

import { GitDiffTool } from '@loopstack/git';

Provided by: GitModule

export class GitDiffTool extends BaseTool<GitDiffArgs, object, GitDiffResult> {
constructor(env: EnvironmentService, remote: RemoteClient);
protected handle(args: GitDiffArgs): Promise<ToolEnvelope<GitDiffResult>>;
}

GitFetchTool

Tool that fetches refs and objects from a remote repository without merging.

import { GitFetchTool } from '@loopstack/git';

Provided by: GitModule

export class GitFetchTool extends BaseTool<GitFetchArgs, object, GitFetchResult> {
constructor(env: EnvironmentService, remote: RemoteClient);
protected handle(args: GitFetchArgs): Promise<ToolEnvelope<GitFetchResult>>;
}

GitLogTool

Tool that returns the git commit log for the workspace repository.

import { GitLogTool } from '@loopstack/git';

Provided by: GitModule

export class GitLogTool extends BaseTool<GitLogArgs, object, GitLogResult> {
constructor(env: EnvironmentService, remote: RemoteClient);
protected handle(args: GitLogArgs): Promise<ToolEnvelope<GitLogResult>>;
}

GitModule

NestJS module that provides the git version control tools (status, add, commit, push, pull, log, diff, fetch, checkout, branch, remote/user config, worktree operations) and the GitController REST API.

Registration:

  • GitModule — bare import; registers all git tools and the REST controller unconditionally.
  • GitModule.forFeature({ enabled?: boolean; environments?: string[] }) — use to feature-gate the module so its tools are only active when enabled and/or limited to specific environments.

Requires: RemoteClientModule must be available in the DI container — every git tool delegates to a remote agent via RemoteClient, so the git commands run on the repository host.

import { GitModule } from '@loopstack/git';
export class GitModule {
static forFeature(config?: { enabled?: boolean; environments?: string[] }): DynamicModule;
}

GitPullTool

Tool that pulls changes from a remote repository.

import { GitPullTool } from '@loopstack/git';

Provided by: GitModule

export class GitPullTool extends BaseTool<GitPullArgs, object, GitPullResult> {
constructor(env: EnvironmentService, remote: RemoteClient);
protected handle(args: GitPullArgs): Promise<ToolEnvelope<GitPullResult>>;
}

GitPushTool

Tool that pushes commits to a remote repository.

import { GitPushTool } from '@loopstack/git';

Provided by: GitModule

export class GitPushTool extends BaseTool<GitPushArgs, object, GitPushResult> {
constructor(env: EnvironmentService, remote: RemoteClient);
protected handle(args: GitPushArgs): Promise<ToolEnvelope<GitPushResult>>;
}

GitRemoteConfigureTool

Tool that configures a git remote, adding it if absent or updating its URL.

import { GitRemoteConfigureTool } from '@loopstack/git';

Provided by: GitModule

export class GitRemoteConfigureTool extends BaseTool<GitRemoteConfigureArgs, object, GitRemoteConfigureResult> {
constructor(env: EnvironmentService, remote: RemoteClient);
protected handle(args: GitRemoteConfigureArgs): Promise<ToolEnvelope<GitRemoteConfigureResult>>;
}

GitStatusTool

Tool that reports the git status of the workspace: current branch plus staged, modified, untracked, and deleted files.

import { GitStatusTool } from '@loopstack/git';

Provided by: GitModule

export class GitStatusTool extends BaseTool<object, object, GitStatusResult> {
constructor(env: EnvironmentService, remote: RemoteClient);
protected handle(): Promise<ToolEnvelope<GitStatusResult>>;
}

GitWorktreeAddTool

Tool that creates a new git worktree at the given path, optionally checking out or creating a branch.

import { GitWorktreeAddTool } from '@loopstack/git';

Provided by: GitModule

export class GitWorktreeAddTool extends BaseTool<GitWorktreeAddArgs, object, GitWorktreeAddResult> {
constructor(env: EnvironmentService, remote: RemoteClient);
protected handle(args: GitWorktreeAddArgs): Promise<ToolEnvelope<GitWorktreeAddResult>>;
}

GitWorktreeListTool

Tool that lists all git worktrees attached to the repository, including path, HEAD, branch, and flags.

import { GitWorktreeListTool } from '@loopstack/git';

Provided by: GitModule

export class GitWorktreeListTool extends BaseTool<object, object, GitWorktreeListResult> {
constructor(env: EnvironmentService, remote: RemoteClient);
protected handle(): Promise<ToolEnvelope<GitWorktreeListResult>>;
}

GitWorktreePruneTool

Tool that prunes worktree administrative files for worktrees whose directories no longer exist.

import { GitWorktreePruneTool } from '@loopstack/git';

Provided by: GitModule

export class GitWorktreePruneTool extends BaseTool<object, object, GitWorktreePruneResult> {
constructor(env: EnvironmentService, remote: RemoteClient);
protected handle(): Promise<ToolEnvelope<GitWorktreePruneResult>>;
}

GitWorktreeRemoveTool

Tool that removes a git worktree at the given path, optionally forcing removal of dirty or locked worktrees.

import { GitWorktreeRemoveTool } from '@loopstack/git';

Provided by: GitModule

export class GitWorktreeRemoveTool extends BaseTool<GitWorktreeRemoveArgs, object, GitWorktreeRemoveResult> {
constructor(env: EnvironmentService, remote: RemoteClient);
protected handle(args: GitWorktreeRemoveArgs): Promise<ToolEnvelope<GitWorktreeRemoveResult>>;
}

Type Aliases

GitAddArgs

Args for GitAddTool.

import { GitAddArgs } from '@loopstack/git';
export type GitAddArgs = {
files: string[];
};

GitAddResult

Result for GitAddTool.

import { GitAddResult } from '@loopstack/git';
export type GitAddResult = {
success: boolean;
};

GitBranchResult

Result for GitBranchTool.

import { GitBranchResult } from '@loopstack/git';
export type GitBranchResult = {
current: string;
branches: {
name: string;
isCurrent: boolean;
}[];
};

GitCheckoutArgs

Args for GitCheckoutTool.

import { GitCheckoutArgs } from '@loopstack/git';
export type GitCheckoutArgs = {
branch: string;
create?: boolean;
};

GitCheckoutResult

Result for GitCheckoutTool.

import { GitCheckoutResult } from '@loopstack/git';
export type GitCheckoutResult = {
branch: string;
};

GitCommit

A single commit entry returned by GitLogTool.

import { GitCommit } from '@loopstack/git';
export type GitCommit = {
hash: string;
shortHash: string;
message: string;
author: string;
date: string;
};

GitCommitArgs

Args for GitCommitTool.

import { GitCommitArgs } from '@loopstack/git';
export type GitCommitArgs = {
message: string;
};

GitCommitResult

Result for GitCommitTool.

import { GitCommitResult } from '@loopstack/git';
export type GitCommitResult = {
hash: string;
message: string;
};

GitConfigUserArgs

Args for GitConfigUserTool.

import { GitConfigUserArgs } from '@loopstack/git';
export type GitConfigUserArgs = {
name: string;
email: string;
};

GitConfigUserResult

Result for GitConfigUserTool.

import { GitConfigUserResult } from '@loopstack/git';
export type GitConfigUserResult = {
success: boolean;
};

GitDiffArgs

Args for GitDiffTool.

import { GitDiffArgs } from '@loopstack/git';
export type GitDiffArgs = {
staged?: boolean;
};

GitDiffFile

A single changed file entry returned by GitDiffTool.

import { GitDiffFile } from '@loopstack/git';
export type GitDiffFile = {
path: string;
status: string;
};

GitDiffResult

Result for GitDiffTool.

import { GitDiffResult } from '@loopstack/git';
export type GitDiffResult = {
files: GitDiffFile[];
};

GitFetchArgs

Args for GitFetchTool.

import { GitFetchArgs } from '@loopstack/git';
export type GitFetchArgs = {
remote?: string;
token?: string;
};

GitFetchResult

Result for GitFetchTool.

import { GitFetchResult } from '@loopstack/git';
export type GitFetchResult = {
success: boolean;
output?: string;
};

GitLogArgs

Args for GitLogTool.

import { GitLogArgs } from '@loopstack/git';
export type GitLogArgs = {
limit?: number;
};

GitLogResult

Result for GitLogTool.

import { GitLogResult } from '@loopstack/git';
export type GitLogResult = {
commits: GitCommit[];
};

GitPullArgs

Args for GitPullTool.

import { GitPullArgs } from '@loopstack/git';
export type GitPullArgs = {
remote?: string;
branch?: string;
token?: string;
};

GitPullResult

Result for GitPullTool.

import { GitPullResult } from '@loopstack/git';
export type GitPullResult = {
success: boolean;
output?: string;
};

GitPushArgs

Args for GitPushTool.

import { GitPushArgs } from '@loopstack/git';
export type GitPushArgs = {
remote?: string;
branch?: string;
force?: boolean;
token?: string;
};

GitPushResult

Result for GitPushTool.

import { GitPushResult } from '@loopstack/git';
export type GitPushResult = {
success: boolean;
output?: string;
};

GitRemoteConfigureArgs

Args for GitRemoteConfigureTool.

import { GitRemoteConfigureArgs } from '@loopstack/git';
export type GitRemoteConfigureArgs = {
url: string;
};

GitRemoteConfigureResult

Result for GitRemoteConfigureTool.

import { GitRemoteConfigureResult } from '@loopstack/git';
export type GitRemoteConfigureResult = {
success: boolean;
};

GitStatusResult

Result for GitStatusTool.

import { GitStatusResult } from '@loopstack/git';
export type GitStatusResult = {
branch: string;
staged: string[];
modified: string[];
untracked: string[];
deleted: string[];
};

GitWorktree

A single worktree entry returned by GitWorktreeListTool.

import { GitWorktree } from '@loopstack/git';
export type GitWorktree = {
path: string;
head?: string;
branch?: string;
bare: boolean;
detached: boolean;
locked?: string;
prunable?: string;
};

GitWorktreeAddArgs

Args for GitWorktreeAddTool.

import { GitWorktreeAddArgs } from '@loopstack/git';
export type GitWorktreeAddArgs = z.infer<typeof GitWorktreeAddSchema>;

GitWorktreeAddResult

Result for GitWorktreeAddTool.

import { GitWorktreeAddResult } from '@loopstack/git';
export type GitWorktreeAddResult = {
success: boolean;
path: string;
output?: string;
};

GitWorktreeListResult

Result for GitWorktreeListTool.

import { GitWorktreeListResult } from '@loopstack/git';
export type GitWorktreeListResult = {
worktrees: GitWorktree[];
};

GitWorktreePruneResult

Result for GitWorktreePruneTool.

import { GitWorktreePruneResult } from '@loopstack/git';
export type GitWorktreePruneResult = {
success: boolean;
output?: string;
};

GitWorktreeRemoveArgs

Args for GitWorktreeRemoveTool.

import { GitWorktreeRemoveArgs } from '@loopstack/git';
export type GitWorktreeRemoveArgs = z.infer<typeof GitWorktreeRemoveSchema>;

GitWorktreeRemoveResult

Result for GitWorktreeRemoveTool.

import { GitWorktreeRemoveResult } from '@loopstack/git';
export type GitWorktreeRemoveResult = {
success: boolean;
};

Variables

GitAddResultSchema

Zod schema for GitAddResult.

import { GitAddResultSchema } from '@loopstack/git';
GitAddResultSchema: z.ZodObject<
{
success: z.ZodBoolean;
},
z.core.$strict
>;

GitBranchResultSchema

Zod schema for GitBranchResult.

import { GitBranchResultSchema } from '@loopstack/git';
GitBranchResultSchema: z.ZodObject<
{
current: z.ZodString;
branches: z.ZodArray<
z.ZodObject<
{
name: z.ZodString;
isCurrent: z.ZodBoolean;
},
z.core.$strict
>
>;
},
z.core.$strict
>;

GitCheckoutResultSchema

Zod schema for GitCheckoutResult.

import { GitCheckoutResultSchema } from '@loopstack/git';
GitCheckoutResultSchema: z.ZodObject<
{
branch: z.ZodString;
},
z.core.$strict
>;

GitCommitResultSchema

Zod schema for GitCommitResult.

import { GitCommitResultSchema } from '@loopstack/git';
GitCommitResultSchema: z.ZodObject<
{
hash: z.ZodString;
message: z.ZodString;
},
z.core.$strict
>;

GitConfigUserResultSchema

Zod schema for GitConfigUserResult.

import { GitConfigUserResultSchema } from '@loopstack/git';
GitConfigUserResultSchema: z.ZodObject<
{
success: z.ZodBoolean;
},
z.core.$strict
>;

GitDiffResultSchema

Zod schema for GitDiffResult.

import { GitDiffResultSchema } from '@loopstack/git';
GitDiffResultSchema: z.ZodObject<
{
files: z.ZodArray<
z.ZodObject<
{
path: z.ZodString;
status: z.ZodString;
},
z.core.$strict
>
>;
},
z.core.$strict
>;

GitFetchResultSchema

Zod schema for GitFetchResult.

import { GitFetchResultSchema } from '@loopstack/git';
GitFetchResultSchema: z.ZodObject<
{
success: z.ZodBoolean;
output: z.ZodOptional<z.ZodString>;
},
z.core.$strict
>;

GitLogResultSchema

Zod schema for GitLogResult.

import { GitLogResultSchema } from '@loopstack/git';
GitLogResultSchema: z.ZodObject<
{
commits: z.ZodArray<
z.ZodObject<
{
hash: z.ZodString;
shortHash: z.ZodString;
message: z.ZodString;
author: z.ZodString;
date: z.ZodString;
},
z.core.$strict
>
>;
},
z.core.$strict
>;

GitPullResultSchema

Zod schema for GitPullResult.

import { GitPullResultSchema } from '@loopstack/git';
GitPullResultSchema: z.ZodObject<
{
success: z.ZodBoolean;
output: z.ZodOptional<z.ZodString>;
},
z.core.$strict
>;

GitPushResultSchema

Zod schema for GitPushResult.

import { GitPushResultSchema } from '@loopstack/git';
GitPushResultSchema: z.ZodObject<
{
success: z.ZodBoolean;
output: z.ZodOptional<z.ZodString>;
},
z.core.$strict
>;

GitRemoteConfigureResultSchema

Zod schema for GitRemoteConfigureResult.

import { GitRemoteConfigureResultSchema } from '@loopstack/git';
GitRemoteConfigureResultSchema: z.ZodObject<
{
success: z.ZodBoolean;
},
z.core.$strict
>;

GitStatusResultSchema

Zod schema for GitStatusResult.

import { GitStatusResultSchema } from '@loopstack/git';
GitStatusResultSchema: z.ZodObject<
{
branch: z.ZodString;
staged: z.ZodArray<z.ZodString>;
modified: z.ZodArray<z.ZodString>;
untracked: z.ZodArray<z.ZodString>;
deleted: z.ZodArray<z.ZodString>;
},
z.core.$strict
>;

GitWorktreeAddResultSchema

Zod schema for GitWorktreeAddResult.

import { GitWorktreeAddResultSchema } from '@loopstack/git';
GitWorktreeAddResultSchema: z.ZodObject<
{
success: z.ZodBoolean;
path: z.ZodString;
output: z.ZodOptional<z.ZodString>;
},
z.core.$strict
>;

GitWorktreeAddSchema

Zod schema for GitWorktreeAddTool arguments.

import { GitWorktreeAddSchema } from '@loopstack/git';
GitWorktreeAddSchema: z.ZodObject<
{
path: z.ZodString;
branch: z.ZodOptional<z.ZodString>;
newBranch: z.ZodOptional<z.ZodBoolean>;
force: z.ZodOptional<z.ZodBoolean>;
},
z.core.$strict
>;

GitWorktreeListResultSchema

Zod schema for GitWorktreeListResult.

import { GitWorktreeListResultSchema } from '@loopstack/git';
GitWorktreeListResultSchema: z.ZodObject<
{
worktrees: z.ZodArray<
z.ZodObject<
{
path: z.ZodString;
head: z.ZodOptional<z.ZodString>;
branch: z.ZodOptional<z.ZodString>;
bare: z.ZodBoolean;
detached: z.ZodBoolean;
locked: z.ZodOptional<z.ZodString>;
prunable: z.ZodOptional<z.ZodString>;
},
z.core.$strict
>
>;
},
z.core.$strict
>;

GitWorktreePruneResultSchema

Zod schema for GitWorktreePruneResult.

import { GitWorktreePruneResultSchema } from '@loopstack/git';
GitWorktreePruneResultSchema: z.ZodObject<
{
success: z.ZodBoolean;
output: z.ZodOptional<z.ZodString>;
},
z.core.$strict
>;

GitWorktreeRemoveResultSchema

Zod schema for GitWorktreeRemoveResult.

import { GitWorktreeRemoveResultSchema } from '@loopstack/git';
GitWorktreeRemoveResultSchema: z.ZodObject<
{
success: z.ZodBoolean;
},
z.core.$strict
>;

GitWorktreeRemoveSchema

Zod schema for GitWorktreeRemoveTool arguments.

import { GitWorktreeRemoveSchema } from '@loopstack/git';
GitWorktreeRemoveSchema: z.ZodObject<
{
path: z.ZodString;
force: z.ZodOptional<z.ZodBoolean>;
},
z.core.$strict
>;