Capisoft.Lib.SharpCursorCli.Linux 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Capisoft.Lib.SharpCursorCli.Linux --version 1.0.0
                    
NuGet\Install-Package Capisoft.Lib.SharpCursorCli.Linux -Version 1.0.0
                    
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="Capisoft.Lib.SharpCursorCli.Linux" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Capisoft.Lib.SharpCursorCli.Linux" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Capisoft.Lib.SharpCursorCli.Linux" />
                    
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 Capisoft.Lib.SharpCursorCli.Linux --version 1.0.0
                    
#r "nuget: Capisoft.Lib.SharpCursorCli.Linux, 1.0.0"
                    
#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 Capisoft.Lib.SharpCursorCli.Linux@1.0.0
                    
#: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=Capisoft.Lib.SharpCursorCli.Linux&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Capisoft.Lib.SharpCursorCli.Linux&version=1.0.0
                    
Install as a Cake Tool

SharpCursorCli

C# wrapper for the Cursor CLI agent. Run the Cursor Agent from .NET with full parameter support, streaming, and optional SQLite persistence for conversation IDs across restarts.

Requirements

Platform support

The library provides implementations for Windows, Linux, and macOS.

Platform Status
Windows ✅ Tested
Linux ⚠️ Not tested — builds included, same API expected
macOS ⚠️ Not tested — builds included, same API expected

If you run SharpCursorCli successfully on Linux or macOS, please open an issue to confirm it works so we can update this section. Feedback and PRs for those platforms are welcome.

Configuration

Copy .env.example to .env and set your Cursor Agent path:

cp .env.example .env

Edit .env:

CURSOR_AGENT_PATH=C:\Users\...\AppData\Local\cursor-agent\agent.ps1

If CURSOR_AGENT_PATH is not set, the wrapper falls back to agent (or agent.cmd on Windows) on PATH.

Quick Start

using Capisoft.Lib.SharpCursorCli;

var runner = CursorAgent.CreateRunner();
var options = new AgentChatOptions()
    .WithPrint()
    .WithPrompt("List files in the current directory")
    .WithOutputFormat(AgentOutputFormat.Text);

var result = await runner.RunAsync(options);
Console.WriteLine($"SessionId: {result.SessionId}");
Console.WriteLine(result.Result);

Stream Mode

With --stream-partial-output, the CLI sends incremental assistant deltas and may also send a final full message. To avoid duplicate output, either print only deltas (AssistantMessageEvent.IsDelta) or deduplicate by skipping a full message that matches already-printed content (see Example.Stream).

var options = new AgentChatOptions()
    .WithPrint()
    .WithPrompt("Explain this codebase")
    .WithOutputFormat(AgentOutputFormat.StreamJson)
    .WithStreamPartialOutput();

await foreach (var evt in runner.RunStreamAsync(options))
{
    if (evt is AssistantMessageEvent assistant when !string.IsNullOrEmpty(assistant.Text))
        Console.Write(assistant.Text); // For no-duplicate output, use dedupe logic as in Example.Stream
}

Resume by Session ID

var options = new AgentChatOptions()
    .WithPrint()
    .WithResume(sessionId)
    .WithPrompt("Continue from where we left off");
var result = await runner.RunAsync(options);

Storage (SQLite)

Lightweight persistence for conversation IDs so you can resume across restarts. See Capisoft.Lib.SharpCursorCli.Storage and the examples.

var storage = new SqliteCursorAgentStorage("conversations.db");
storage.SaveConversation(result.SessionId, result.RequestId, promptPreview: "List files...");
var recent = storage.GetRecentConversations(10);

Solution Structure

Project Description
Capisoft.Lib.SharpCursorCli.Abstractions Interfaces, options, result and stream event DTOs
Capisoft.Lib.SharpCursorCli Main library; facade and platform detection
Capisoft.Lib.SharpCursorCli.Windows Windows implementation (agent path from .env or PATH)
Capisoft.Lib.SharpCursorCli.Linux Linux implementation (agent path from .env or PATH)
Capisoft.Lib.SharpCursorCli.OSX macOS implementation (agent path from .env or PATH)
Capisoft.Lib.SharpCursorCli.Storage Lightweight SQLite storage for conversation IDs

Repository layout

  • Library only: build from repo root with SharpCursorCli.sln.
  • Examples: they reference the library via relative paths. From repo root: dotnet run --project examples/Example.RunAsync (or open examples/SharpCursorCli.Examples.sln).

Examples

Separate, minimal examples per use case are in examples/:

  • Example.RunAsync – Print mode, single run, get AgentRunResult
  • Example.Stream – Stream mode with IAsyncEnumerable<StreamEvent>
  • Example.Resume – Resume by session ID
  • Example.Storage – Save/load conversations with SQLite
  • Example.FullFlow – Run → save → resume (end-to-end)

Copy .env.example to .env in the repo root (or in the example project) and set CURSOR_AGENT_PATH before running examples.

Edge cases and limitations

For known edge cases (path resolution, timeouts, cancellation, encoding, storage), see docs/EDGE_CASES.md.

Cursor CLI Reference

Maintenance and contributions

Maintenance time for this project is limited, but issues are welcome—please open one if you hit a bug or have a question. Pull requests are appreciated when something is really needed; I’ll try to review and merge them as often as possible. I’ll also do my best to triage and address issues when I can. Thanks for your understanding.

License

MIT

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 (1)

Showing the top 1 NuGet packages that depend on Capisoft.Lib.SharpCursorCli.Linux:

Package Downloads
Capisoft.Lib.SharpCursorCli

C# wrapper for the Cursor CLI agent. Run the Cursor Agent from .NET with full parameter support, streaming, and optional SQLite persistence for conversation IDs.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 95 2/1/2026
1.0.0 97 2/1/2026