forked from badlogic/pi-mono
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreload-runtime.ts
More file actions
37 lines (34 loc) · 1.14 KB
/
reload-runtime.ts
File metadata and controls
37 lines (34 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* Reload Runtime Extension
*
* Demonstrates ctx.reload() from ExtensionCommandContext and an LLM-callable
* tool that queues a follow-up command to trigger reload.
*/
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
import { Type } from "@sinclair/typebox";
export default function (pi: ExtensionAPI) {
// Command entrypoint for reload.
// Treat reload as terminal for this handler.
pi.registerCommand("reload-runtime", {
description: "Reload extensions, skills, prompts, and themes",
handler: async (_args, ctx) => {
await ctx.reload();
return;
},
});
// LLM-callable tool. Tools get ExtensionContext, so they cannot call ctx.reload() directly.
// Instead, queue a follow-up user command that executes the command above.
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: {},
};
},
});
}