feat: add /export-session command

Export current session to HTML file with full system prompt included.
Uses pi-coding-agent templates for consistent rendering.

Features:
- Exports session entries + full system prompt + tools
- Saves to workspace by default, or custom path
- Optional --open flag to open in browser
- Reuses pi-mono export-html templates

Usage:
  /export-session           # Export to workspace
  /export-session ~/export  # Export to custom path
  /export-session --open    # Export and open in browser
This commit is contained in:
boris
2026-02-16 11:49:14 +01:00
committed by Peter Steinberger
parent 3c3a39d165
commit add3afb743
4 changed files with 386 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import {
buildHelpMessage,
} from "../status.js";
import { buildContextReply } from "./commands-context-report.js";
import { buildExportSessionReply } from "./commands-export-session.js";
import { buildStatusReply } from "./commands-status.js";
export const handleHelpCommand: CommandHandler = async (params, allowTextCommands) => {
@@ -168,6 +169,28 @@ export const handleContextCommand: CommandHandler = async (params, allowTextComm
return { shouldContinue: false, reply: await buildContextReply(params) };
};
export const handleExportSessionCommand: CommandHandler = async (params, allowTextCommands) => {
if (!allowTextCommands) {
return null;
}
const normalized = params.command.commandBodyNormalized;
if (
normalized !== "/export-session" &&
!normalized.startsWith("/export-session ") &&
normalized !== "/export" &&
!normalized.startsWith("/export ")
) {
return null;
}
if (!params.command.isAuthorizedSender) {
logVerbose(
`Ignoring /export-session from unauthorized sender: ${params.command.senderId || "<unknown>"}`,
);
return { shouldContinue: false };
}
return { shouldContinue: false, reply: await buildExportSessionReply(params) };
};
export const handleWhoamiCommand: CommandHandler = async (params, allowTextCommands) => {
if (!allowTextCommands) {
return null;