Add a proper public-facing documentation site using Mintlify with 19 MDX pages covering getting started, auto mode, commands, configuration, and all user-facing features. Move internal/SDK documentation (Pi SDK, TUI, context & hooks, research notes, ADRs) to docs-internal/ since they should not be part of the public documentation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1.2 KiB
1.2 KiB
Custom Commands — User-Facing Actions
Commands let users invoke your extension directly via /mycommand.
pi.registerCommand("deploy", {
description: "Deploy to an environment",
// Optional: argument auto-completion
getArgumentCompletions: (prefix: string) => {
const envs = ["dev", "staging", "prod"];
return envs
.filter(e => e.startsWith(prefix))
.map(e => ({ value: e, label: e }));
},
handler: async (args, ctx) => {
// args = everything after "/deploy "
// ctx = ExtensionCommandContext (has extra session control methods)
await ctx.waitForIdle(); // Wait for agent to finish
ctx.ui.notify(`Deploying to ${args}`, "info");
},
});
Command Context Extras
Command handlers get ExtensionCommandContext which extends ExtensionContext with:
ctx.waitForIdle()— Wait for agent to finishctx.newSession(options?)— Create a new sessionctx.fork(entryId)— Fork from an entryctx.navigateTree(targetId, options?)— Navigate the session treectx.reload()— Hot-reload everything
Important: These methods are only available in commands, not in event handlers, because they would deadlock there.