NOpenCode 0.1.4

dotnet add package NOpenCode --version 0.1.4
                    
NuGet\Install-Package NOpenCode -Version 0.1.4
                    
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="NOpenCode" Version="0.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NOpenCode" Version="0.1.4" />
                    
Directory.Packages.props
<PackageReference Include="NOpenCode" />
                    
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 NOpenCode --version 0.1.4
                    
#r "nuget: NOpenCode, 0.1.4"
                    
#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 NOpenCode@0.1.4
                    
#: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=NOpenCode&version=0.1.4
                    
Install as a Cake Addin
#tool nuget:?package=NOpenCode&version=0.1.4
                    
Install as a Cake Tool

NOpenCode

NuGet CI Examples README

Empower your .NET applications with OpenCode's AI engine. Express your intent in natural language — NOpenCode bridges your application logic with AI.

✨ Features

  • Zero setup — auto-discovers or starts opencode serve for you
  • Plain-English API — reads like natural language
  • Multi-turn sessions — ask follow-up questions in context
  • Streaming — receive responses chunk by chunk
  • File & code search — ripgrep, filename lookup, symbol search
  • Session management — fork, share, diff, revert, summarize
  • Provider & model discovery — list available models, providers, agents
  • MCP server management — add and list MCP servers
  • Event monitoring — subscribe to real-time SSE events
  • DI integrationAddNOpenCode() for ASP.NET Core / console hosts
  • .NET Standard 2.0 — compatible with .NET Framework 4.6.1+ and all modern .NET

📋 Prerequisites

  • OpenCode CLI installed (npm install -g opencode-ai)
  • .NET SDK 8+ (for consumption) or .NET 10 (for development)

📦 Installation

dotnet add package NOpenCode

🚀 Quick Start

using NOpenCode;

string answer = await OpenCode.Ask("Explain how async/await works in C#");
Console.WriteLine(answer);

💡 Examples

🎯 One-shot

string review = await OpenCode.Ask(
    "What is the capital of France?",
    cfg => cfg.WithModel("opencode/deepseek-v4-flash-free")
);

// Or use the builder for full control
await using var ai = await OpenCode
    .Configure()
    .WithModel("opencode/deepseek-v4-flash-free")
    .Launch();

var reply = await ai
    .Ask("What is the population of Paris?")
    .Execute();

Console.WriteLine(reply);

💬 Multi-turn

await using var ai = await OpenCode
    .Configure()
    .WithModel("opencode/mimo-v2.5-free")
    .Launch();

var session = await ai.NewSession("API design").Create();

var r1 = await session.Ask("What are the key differences between REST and GraphQL?");
var r2 = await session.Ask("When would you choose one over the other?");

🔄 Streaming

await session.AskStream(
    "Write a brief README for a .NET library called NOpenCode.",
    onChunk: chunk => Console.Write(chunk),
    onComplete: reply => Console.WriteLine($"\nDone, tokens: {reply.GetUsage()?.Total}"),
    onError: ex => Console.WriteLine($"Error: {ex.Message}")
);

📋 Session lifecycle

var session = await ai.NewSession("Code review").Create();
await session.Ask("Review this code for potential bugs.");

// Fork into a new branch
var fork = await session.Fork();
await fork.Ask("Focus on security issues only.");

// Get the diff
var diff = await fork.GetDiff();
foreach (var d in diff)
    Console.WriteLine($"[{d.Type}] {d.Path}");

// Share the session
await fork.Share();

// Clean up
await fork.Delete();
var todos = await ai.Files.Search("TODO|FIXME");
foreach (var match in todos)
    Console.WriteLine($"{match.Path}:{match.LineNumber}  {match.Lines?.Trim()}");

var files = await ai.Files.Find("*.cs");
var content = await ai.Files.Read("Program.cs");

🗺️ Discovery

var models = await ai.Models.List("opencode");
var providers = await ai.Providers.List();
var agents = await ai.Agents.List();
var health = await ai.Diagnostics.GetHealth();

🔌 MCP server management

await ai.Mcp.Add("filesystem", new
{
    type = "local",
    command = new[] { "npx", "-y", "@modelcontextprotocol/server-filesystem", "./" }
});

var servers = await ai.Mcp.List();

🧩 DI integration

builder.Services.AddNOpenCode(cfg => cfg
    .WithModel("opencode/deepseek-v4-flash-free")
);

public class ReviewService(OpenCodeClient AI)
{
    public async Task RunAsync()
    {
        var reply = await AI
            .Ask("What is the capital of France?")
            .Execute();
    }
}

📡 Real-time events

var subscribed = ai.Events.Subscribe(
    onEvent: evt => Console.WriteLine($"[{evt.Type}] {evt.Data}"),
    onError: ex => Console.WriteLine($"Error: {ex.Message}")
);

var answer = await ai.Ask("What is 2+2?").Execute();
Console.WriteLine($"Answer: {answer}");

await Task.Delay(2000);
// subscribed completes when cancelled

📁 Project Structure

src/NOpenCode/              → .NET Standard 2.0 library
  OpenCode.cs               → Static entry point
  NOpenCodeBuilder.cs       → Fluent builder
  OpenCodeClient.cs         → Main client with 11 sub-clients
  OpenCodeSession.cs        → Session with full lifecycle
  AskOperation.cs           → One-shot query builder
  SessionBuilder.cs         → Session creation builder
  ServerManager.cs          → Auto-manages opencode serve
  Clients/                  → Domain-specific clients
  Models/                   → 14 DTOs
  Http/                     → HTTP client + SSE reader
  DependencyInjection/      → IServiceCollection extensions
  Exceptions/               → Custom exception hierarchy

examples/                   → 10 example projects (net10.0)
  01-HelloWorld
  02-OneShot
  03-MultiTurn
  04-Streaming
  05-DI
  06-SessionLifecycle
  07-FileSearch
  08-Discovery
  09-McpManagement
  10-EventMonitor

tests/NOpenCode.Tests/      → xUnit tests

📄 License

MIT

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.1.4 32 6/3/2026
0.1.0 54 6/2/2026