Pi's extensions, or yours in C#
PiSharp runs Pi's TypeScript extensions and packages as they are. You can also add tools, slash commands and lifecycle hooks with a plain C# class, loaded from the same folders.
Pi's TypeScript extensions
Drop them in ~/.pi/agent/extensions or install a package with pisharp install. PiSharp runs them in Node on Pi's own npm packages, with the whole extension API.
Native C# extensions
Implement IPiSharpExtension, add a pisharp-extension.json, and put the folder next to your Pi extensions. In-process and typed, with no Node.
Same extension, two languages
The TypeScript version runs in PiSharp as it is. The C# sample is a port of it. If you've written one for Pi, you already know the shape.
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) { /* … */ } }, }); }
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
- StatefulTodoA todo tool whose state is rebuilt from the current session branch, so it stays correct when you branch. A tool, ported from Pi.
- SessionCheckpointRegisters a
/checkpointcommand, a session-start observer and a pre-switch handler that saves and restores session checkpoints. Commands and session hooks.
Community extensions
Pi packages install with pisharp install. A catalog of C# extensions will appear here. Building one? Open an issue on GitHub so it can be listed.