diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-20 20:49:39 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-20 20:49:39 +0200 |
| commit | 097afe5a81849ea8a921286c887014e242fa3794 (patch) | |
| tree | 09b035931cbca6793b370c33a490f094d8315b37 /pi/agent/extensions/reload-runtime | |
| parent | e66e46fcc27aee1246f40b76fedd87d2138e6d15 (diff) | |
Add Pi extensions and usage docs
Diffstat (limited to 'pi/agent/extensions/reload-runtime')
| -rw-r--r-- | pi/agent/extensions/reload-runtime/README.md | 46 | ||||
| -rw-r--r-- | pi/agent/extensions/reload-runtime/index.ts | 26 |
2 files changed, 72 insertions, 0 deletions
diff --git a/pi/agent/extensions/reload-runtime/README.md b/pi/agent/extensions/reload-runtime/README.md new file mode 100644 index 0000000..1c209d5 --- /dev/null +++ b/pi/agent/extensions/reload-runtime/README.md @@ -0,0 +1,46 @@ +# Reload Runtime + +Runtime reload support for Pi. + +This is the upstream `reload-runtime.ts` example installed as a local extension +in your dotfiles-backed Pi tree. Pi does not ship a `reload-runtime.sh` +extension in the bundled examples; the actual upstream example is TypeScript and +registers both a slash command and a tool. + +## What It Does + +- adds `/reload-runtime` +- adds the `reload_runtime` tool +- reloads extensions, skills, prompts, and themes in the current Pi session + +## Usage Flows + +### Flow 1: Reload after editing dotfiles + +1. Edit an extension, skill, prompt, or theme on disk. +2. In the same Pi session, run: + +```text +/reload-runtime +``` + +3. Pi reloads the runtime without restarting the process. + +### Flow 2: Let the agent request a reload + +Because this also exposes a tool, the agent can ask to reload the runtime when +that makes sense: + +```text +Use the reload_runtime tool after updating the extension files so the new command set is active. +``` + +The tool queues `/reload-runtime` as a follow-up command. + +## Notes And Limits + +- Reload affects the current Pi session only. +- It is most useful in an interactive session that stays open while you are + editing your Pi configuration. +- In one-shot `pi -p` usage, reload is usually not very interesting because the + process exits immediately after handling the prompt. diff --git a/pi/agent/extensions/reload-runtime/index.ts b/pi/agent/extensions/reload-runtime/index.ts new file mode 100644 index 0000000..ebe6b7f --- /dev/null +++ b/pi/agent/extensions/reload-runtime/index.ts @@ -0,0 +1,26 @@ +import type { ExtensionAPI } from "@mariozechner/pi-coding-agent"; +import { Type } from "@sinclair/typebox"; + +export default function (pi: ExtensionAPI) { + pi.registerCommand("reload-runtime", { + description: "Reload extensions, skills, prompts, and themes", + handler: async (_args, ctx) => { + await ctx.reload(); + return; + }, + }); + + pi.registerTool({ + name: "reload_runtime", + label: "Reload Runtime", + description: "Reload extensions, skills, prompts, and themes", + parameters: Type.Object({}), + async execute() { + pi.sendUserMessage("/reload-runtime", { deliverAs: "followUp" }); + return { + content: [{ type: "text", text: "Queued /reload-runtime as a follow-up command." }], + details: {}, + }; + }, + }); +} |
