continue-custom/core/commands/slash/share.ts
Nate Sesti e1ed7ed0a2 ✨ config.ts
2023-12-14 12:47:01 -08:00

24 lines
760 B
TypeScript

import { SlashCommand } from "../..";
const ShareSlashCommand: SlashCommand = {
name: "share",
description: "Download and share this session",
run: async function* ({ ide, history }) {
let content = `This is a session transcript from [Continue](https://continue.dev) on ${new Date().toLocaleString()}.`;
for (const msg of history) {
content += `\n\n## ${msg.role === "user" ? "User" : "Continue"}\n\n${
msg.content
}`;
}
const continueDir = await ide.getContinueDir();
const path = `${continueDir}/session.md`;
await ide.writeFile(path, content);
await ide.openFile(path);
yield `The session transcript has been saved to a markdown file at \`${path}\`.`;
},
};
export default ShareSlashCommand;