forked from continuedev/continue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshare.ts
25 lines (20 loc) · 826 Bytes
/
share.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { SlashCommand } from "../..";
import { stripImages } from "../../llm/countTokens";
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${stripImages(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;