-
Notifications
You must be signed in to change notification settings - Fork 0
Tier 1 API
Cadenza exposes a small, curated surface as bare names — callable with no using directives, because each SDK adds global using static for the right classes. Tier 1 stays ≤ 10 names per SDK and is the same across every variant where it makes sense.
This page lists the surface as it ships in 1.0.x. The authoritative source is the code under src/; this is a user-facing summary.
Convention used below: a name shown as
Foois callable bare. A name shown asFoo.Baris reached through the (bare) typeFoo.
These are available everywhere — they live in Cadenza.* packages that every SDK ships.
string Fs.ReadText(string path);
Task<string> Fs.ReadTextAsync(string path);
void Fs.WriteText(string path, string content); // UTF-8, no BOM
byte[] Fs.ReadBytes(string path);
void Fs.WriteBytes(string path, byte[] content);
bool Fs.Exists(string path);
void Fs.Delete(string path);
void Fs.Move(string src, string dst);
void Fs.Copy(string src, string dst);
void Fs.MakeDir(string path);
IEnumerable<string> Fs.Glob(string pattern); // **/*.cs etc.
TempDirectory Fs.TempDir(); // IDisposableReadText, WriteText, and Glob are also exported as plain bare names (no Fs. prefix) on Console / Worker / Web / Mcp / Agent.
int Sh.Run(string cmd, bool throwOnError = false); // returns exit code
string Sh.Capture(string cmd); // stdout, throws on non-zero
string Sh.Pipe(string cmd, string stdin);
Task<int> Sh.RunAsync(string cmd, CancellationToken ct);
Task<string> Sh.CaptureAsync(string cmd, CancellationToken ct);On Console / Worker / Web / Agent, Run and Capture are also bare. Not on Mcp — see "Per-SDK notes".
Task<T> Http.GetJson<T>(string url, JsonTypeInfo<T> ctx, CancellationToken ct = default);
Task<TResp> Http.PostJson<TReq, TResp>(string url, TReq body,
JsonTypeInfo<TReq> reqCtx, JsonTypeInfo<TResp> respCtx, CancellationToken ct = default);
Task<string> Http.GetText(string url, CancellationToken ct = default);
Task Http.Download(string url, string path, CancellationToken ct = default);
HttpClient Http.Client { get; } // for full-fat scenariosstring? Env.Get(string key);
string Env.Get(string key, string @default);
string[] Env.Args { get; }
string Env.Cwd { get; }
string Env.ScriptPath { get; } // path to the running .cs
string Env.ScriptDirectory { get; } // its directory
void Env.Exit(int code);
bool Env.IsCi { get; } // CI env detection
bool Env.IsWindows / .IsMacOS / .IsLinux { get; }T? Json.Parse<T>(string json, JsonTypeInfo<T> ctx);
string Json.Stringify<T>(T value, JsonTypeInfo<T> ctx);Both take a JsonTypeInfo<T> (source-generated context) so they're AOT-clean.
Available on Console / Worker / Web (not Mcp, not Agent — those SDKs don't own the terminal).
bool Prompt.Confirm(string question, bool @default = false);
T Prompt.Select<T>(string question, IEnumerable<T> options);
string Prompt.Text(string question, string? @default = null);
string Prompt.Password(string question);WriteLine, Write, ReadLine are exposed via using static System.Console on Console / Worker / Web / Agent.
Not on Mcp — Mcp owns stdio for JSON-RPC. Writing to stdout would corrupt the protocol; use Log.Info(...) instead.
The same shared surface above, plus:
-
Sh.Run/Sh.Captureare bare →Run("git status"),Capture("git rev-parse HEAD"). -
Fs.ReadText/Fs.WriteText/Fs.Globare bare →ReadText("file"),Glob("**/*.cs"). - No host — the script runs top to bottom and exits.
The shared surface (without Prompt is technically still available but inadvisable in a daemon), plus:
Task Worker.Run(Func<CancellationToken, Task> work);
Task Worker.Run(Func<IServiceProvider, CancellationToken, Task> work); // DI variant
T? Worker.Config<T>(string key);
T Worker.Service<T>();-
Runis bare →await Run(async ct => { … }); -
Log.Info / Warn / Error / Debugroute throughILogger.
RouteHandlerBuilder Web.Get(string path, Delegate handler);
RouteHandlerBuilder Web.Post(string path, Delegate handler);
RouteHandlerBuilder Web.Put(string path, Delegate handler);
RouteHandlerBuilder Web.Delete(string path, Delegate handler);
IEndpointConventionBuilder Web.Map(string path, Delegate handler);
Task Web.Run();
void Web.UseHttps();
void Web.UseCors(string policy = "default");
IServiceCollection Web.Services { get; } // add DI services
WebApplication Web.App { get; } // drop down to raw ASP.NET CoreGet / Post / Put / Delete / Map / Run / UseHttps / UseCors are bare.
Bind URL is configured via standard ASP.NET Core mechanisms: the ASPNETCORE_URLS environment variable, the --urls CLI argument, or Web.App.Urls.Add(...). See Cadenza Web and Deployment Container.
void Mcp.Tool(string name, string description, Delegate handler);
void Mcp.Resource(string uri, string name, Delegate handler);
void Mcp.Prompt(string name, string description, Delegate handler);
Task Mcp.Run();All four are bare. Cadenza infers the JSON schema for tool inputs from the handler's parameter types.
Log.Info / Warn / Error / Debug are available; WriteLine and friends are deliberately not — stdout belongs to the MCP JSON-RPC framing.
void Agent.Tool(string name, string description, Delegate handler);
void Agent.SystemPrompt(string text);
void Agent.UseOllama(string model, string baseUrl = "http://localhost:11434");
void Agent.UseOpenAi(string model, string? apiKey = null);
void Agent.UseAnthropic(string model, string? apiKey = null);
void Agent.UseAzureOpenAi(string endpoint, string deploymentName, string? apiKey = null);
void Agent.UseChatClient(IChatClient client); // escape hatch (OpenRouter, custom, …)
Task Agent.Run(); // OpenAI-compatible HTTP server (Chat Completions + Responses)
Task Agent.ChatLoop(); // local REPL
Task<string> Agent.Reply(string prompt);And these mutable properties on the Agent type:
Agent.Port { get; set; } = 8080;
Agent.HostName { get; set; } = "localhost";
Agent.ServedModelName { get; set; } = "cadenza-agent";Set them like HostName = "0.0.0.0"; Port = 9000; before await Run(). See Cadenza Agent for OpenRouter and Codex CLI patterns.
-
Cadenza.Agentis not AOT-clean today —Microsoft.Extensions.AI's function-invocation middleware uses reflection. The other four SDKs are AOT-clean. - The
Sh.*/Fs.*/Http.*/Env.*/Json.*modules are stable across all SDKs and are intentionally the same shape everywhere. - The full type signatures (
JsonTypeInfo<T>forHttpandJson, etc.) make every API AOT-safe by construction — see the spec, §4 onward, for the formal contract.
-
Directives —
#:sdk,#:package,#:include,#:property - Samples — every Tier 1 name has a working sample
-
Source:
src/— authoritative surface
Cadenza · MIT · .NET 10+ · github.com/rkttu/cadenza · No orchestra. No project. Just one file, playing solo.