Pmad.Git.CliEmulator.AI 0.2.8

dotnet add package Pmad.Git.CliEmulator.AI --version 0.2.8
                    
NuGet\Install-Package Pmad.Git.CliEmulator.AI -Version 0.2.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Pmad.Git.CliEmulator.AI" Version="0.2.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pmad.Git.CliEmulator.AI" Version="0.2.8" />
                    
Directory.Packages.props
<PackageReference Include="Pmad.Git.CliEmulator.AI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Pmad.Git.CliEmulator.AI --version 0.2.8
                    
#r "nuget: Pmad.Git.CliEmulator.AI, 0.2.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Pmad.Git.CliEmulator.AI@0.2.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Pmad.Git.CliEmulator.AI&version=0.2.8
                    
Install as a Cake Addin
#tool nuget:?package=Pmad.Git.CliEmulator.AI&version=0.2.8
                    
Install as a Cake Tool

Pmad.Git.CliEmulator.AI

Microsoft.Extensions.AI integration for Pmad.Git.CliEmulator.

Exposes the managed Git CLI emulator as a single git AIFunction that any IChatClient-based agent pipeline can call as a tool — no native git binary required.

Features

  • One git tool, all sub-commands — status, log, diff, show, add, restore, commit, reset, revert, merge, branch, tag, config, remote, ls-tree, rev-parse, cat-file, fetch, pull, push.
  • Array-args or string-args — pick the variant that best matches the model you're using.
  • Safe by default — gated operations (destructive and network operations) are denied automatically unless you supply an IUserApproval implementation.
  • DI-friendly — one-line IServiceCollection registration via AddGitCliEmulatorAI.
  • No native Git dependency — pure managed C#, AOT-compatible via the underlying Pmad.Git.CliEmulator.

Quick Start

Option A — Extension method on the emulator

using Pmad.Git.CliEmulator;
using Pmad.Git.CliEmulator.AI;
using Microsoft.Extensions.AI;

using var emulator = GitCliEmulator.Open("/path/to/repo");

AIFunction gitTool = emulator.CreateAIFunction();

IChatClient client = new ChatClientBuilder(innerClient)
    .UseFunctionInvocation()
    .Build();

var response = await client.CompleteAsync(
    "What files have changed since the last commit?",
    new ChatOptions { Tools = [gitTool] });

Option B — Factory directly

using Pmad.Git.CliEmulator;
using Pmad.Git.CliEmulator.AI;

using var emulator = GitCliEmulator.Open("/path/to/repo");

// Array-args variant (recommended — most models handle JSON arrays well)
AIFunction gitTool = GitAIFunctionFactory.Create(emulator);

// String-args variant (for models that prefer a single string)
AIFunction gitToolStr = GitAIFunctionFactory.CreateFromString(emulator);

Option C — Dependency injection

// Program.cs / Startup.cs
using Pmad.Git.CliEmulator.AI;
using Pmad.Git.RemoteClient;

builder.Services.AddGitCliEmulatorAI(
    repositoryPath: "/path/to/repo",
    remoteOptions: new GitRemoteClientOptions
    {
        Credentials = new GitHttpCredentials("pat", Environment.GetEnvironmentVariable("GH_TOKEN")!)
    });

// Inject AIFunction (or IEnumerable<AIFunction>) wherever you build your agent:
app.MapGet("/agent", async (AIFunction gitTool, IChatClient chat) =>
{
    var options = new ChatOptions { Tools = [gitTool] };
    var response = await chat
        .AsBuilder().UseFunctionInvocation().Build()
        .CompleteAsync("Summarise recent commits", options);
    return response.Message.Text;
});

Approval Gates

By default, gated operations (destructive operations like reset --hard or network operations like push) are denied (DenyApproval.Instance) to protect repositories from unintended AI modifications. To permit gated operations or implement custom approval logic, provide an IUserApproval implementation (or AutoApproval.Instance to approve all operations) to any of the factory or extension methods:

IUserApproval myApproval = new MyApproval(CancellationToken.None);

AIFunction gitTool = emulator.CreateAIFunction(myApproval);
// or
AIFunction gitTool = GitAIFunctionFactory.Create(emulator, myApproval);

Package

Package NuGet
Pmad.Git.CliEmulator.AI NuGet

Dependencies

Package Purpose
Pmad.Git.CliEmulator Core Git CLI emulator
Microsoft.Extensions.AI.Abstractions AIFunction, AIFunctionFactory
Microsoft.Extensions.DependencyInjection.Abstractions IServiceCollection extensions
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.8 101 10/8/2026
0.2.7 106 10/4/2026