mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 13:03:42 +00:00
feat(coding-agent): add ctx.reload and reload-runtime example closes #1371
This commit is contained in:
parent
0bd205ab87
commit
e1b56c1d28
8 changed files with 114 additions and 0 deletions
|
|
@ -66,6 +66,7 @@ cp permission-gate.ts ~/.pi/agent/extensions/
|
|||
| `overlay-qa-tests.ts` | Comprehensive overlay QA tests: anchors, margins, stacking, overflow, animation |
|
||||
| `doom-overlay/` | DOOM game running as an overlay at 35 FPS (demonstrates real-time game rendering) |
|
||||
| `shutdown-command.ts` | Adds `/quit` command demonstrating `ctx.shutdown()` |
|
||||
| `reload-runtime.ts` | Adds `/reload-runtime` and `reload_runtime` tool showing safe reload flow |
|
||||
| `interactive-shell.ts` | Run interactive commands (vim, htop) with full terminal via `user_bash` hook |
|
||||
| `inline-bash.ts` | Expands `!{command}` patterns in prompts via `input` event transformation |
|
||||
|
||||
|
|
|
|||
37
packages/coding-agent/examples/extensions/reload-runtime.ts
Normal file
37
packages/coding-agent/examples/extensions/reload-runtime.ts
Normal file
|
|
@ -0,0 +1,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: {},
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue