From 3b9a8c1c6326bd5ece1a9e82be87d1484fe4d2d5 Mon Sep 17 00:00:00 2001 From: jonathancostin <66714927+jonathancostin@users.noreply.github.com> Date: Wed, 11 Mar 2026 16:45:34 -0500 Subject: [PATCH] feat: add /clear as alias for /new slash command (#59) Registers /clear as a command that calls ctx.newSession(), identical to /new. Shows in autocomplete when typing /cl with 'Alias for /new' description. --- src/resources/extensions/slash-commands/clear.ts | 10 ++++++++++ src/resources/extensions/slash-commands/index.ts | 2 ++ 2 files changed, 12 insertions(+) create mode 100644 src/resources/extensions/slash-commands/clear.ts diff --git a/src/resources/extensions/slash-commands/clear.ts b/src/resources/extensions/slash-commands/clear.ts new file mode 100644 index 000000000..75e21f878 --- /dev/null +++ b/src/resources/extensions/slash-commands/clear.ts @@ -0,0 +1,10 @@ +import type { ExtensionAPI, ExtensionCommandContext } from "@mariozechner/pi-coding-agent"; + +export default function clearCommand(pi: ExtensionAPI) { + pi.registerCommand("clear", { + description: "Alias for /new — start a new session", + async handler(_args: string, ctx: ExtensionCommandContext) { + await ctx.newSession(); + }, + }); +} diff --git a/src/resources/extensions/slash-commands/index.ts b/src/resources/extensions/slash-commands/index.ts index 6ea3c683a..8d3be0e02 100644 --- a/src/resources/extensions/slash-commands/index.ts +++ b/src/resources/extensions/slash-commands/index.ts @@ -3,10 +3,12 @@ import createSlashCommand from "./create-slash-command.js"; import createExtension from "./create-extension.js"; import auditCommand from "./audit.js"; import gsdRun from "./gsd-run.js"; +import clearCommand from "./clear.js"; export default function slashCommands(pi: ExtensionAPI) { createSlashCommand(pi); createExtension(pi); auditCommand(pi); gsdRun(pi); + clearCommand(pi); }