Skip to content
Extensions

Shape the harness in C#

Add tools, slash commands, shortcuts, renderers and lifecycle hooks with a plain C# class. Package it for NuGet and share it.

RECOMMENDED

Native C# extensions

Implement IPiSharpExtension, register what you need, and ship a NuGet package. In-process, typed, no Node.

Build an extension →
OPTIONAL

Pi extensions via the Node bridge

Run existing TypeScript extensions in a supervised Node worker. Support is tiered, and anything unsupported is reported at startup instead of being silently ignored.

Bridge compatibility →

Same extension, two languages

The sample todo extension is ported from Pi's own example. If you've written one for Pi, you already know the shape.

Pi · todo.tsTypeScript
export default function (pi: ExtensionAPI) {
  pi.registerTool({
    name: "todo",
    label: "Todo",
    description: "Manage a todo list. …",
    parameters: TodoParams,

    async execute(_id, params, …) {
      switch (params.action) { /* … */ }
    },
  });
}
PiSharp · StatefulTodoExtension.csC#
public sealed class StatefulTodoExtension
    : IPiSharpExtension
{
  public ValueTask InitializeAsync(
      IExtensionRegistry registry, CancellationToken ct)
  {
    registry.RegisterTool(new("todo", "todo",
        Description, JsonData.Parse(ParametersJson),
        ExecuteAsync));
    return ValueTask.CompletedTask;
  }
}

Samples

Community extensions

A catalog of community extensions published to NuGet will appear here. Building one? Open an issue on GitHub so it can be listed.