| 1 | import { fileURLToPath } from "node:url"; |
| 2 | import path from "path"; |
| 3 | |
| 4 | import { SlashCommand } from "../../../index.js"; |
| 5 | import { shareSession } from "../../../util/historyUtils.js"; |
| 6 | |
| 7 | const ShareSlashCommand: SlashCommand = { |
| 8 | name: "share", |
| 9 | description: "Export the current chat session to markdown", |
| 10 | run: async function* ({ ide, history, params }) { |
| 11 | const fileUrl = await shareSession(ide, history, params?.outputDir); |
| 12 | const filePath = fileURLToPath(fileUrl); |
| 13 | // output path is the parent directory of the filePath |
| 14 | const outPath = path.dirname(filePath); |
| 15 | yield `The session transcript has been saved to a markdown file at \`${outPath}\`.`; |
| 16 | }, |
| 17 | }; |
| 18 | |
| 19 | export default ShareSlashCommand; |