Add outputDir param to /share
This commit is contained in:
parent
faabd384a1
commit
fadf70ed61
7 changed files with 23 additions and 12 deletions
|
|
@ -1,10 +1,11 @@
|
|||
import path from "path";
|
||||
import { SlashCommand } from "../..";
|
||||
import { stripImages } from "../../llm/countTokens";
|
||||
|
||||
const ShareSlashCommand: SlashCommand = {
|
||||
name: "share",
|
||||
description: "Download and share this session",
|
||||
run: async function* ({ ide, history }) {
|
||||
run: async function* ({ ide, history, params }) {
|
||||
let content = `This is a session transcript from [Continue](https://continue.dev) on ${new Date().toLocaleString()}.`;
|
||||
|
||||
for (const msg of history) {
|
||||
|
|
@ -13,10 +14,14 @@ const ShareSlashCommand: SlashCommand = {
|
|||
}\n\n${stripImages(msg.content)}`;
|
||||
}
|
||||
|
||||
const continueDir = await ide.getContinueDir();
|
||||
const path = `${continueDir}/session.md`;
|
||||
await ide.writeFile(path, content);
|
||||
await ide.openFile(path);
|
||||
let outputDir = params?.outputDir;
|
||||
if (!outputDir) {
|
||||
outputDir = await ide.getContinueDir();
|
||||
}
|
||||
|
||||
const outPath = path.join(outputDir, `session.md`);
|
||||
await ide.writeFile(outPath, content);
|
||||
await ide.openFile(outPath);
|
||||
|
||||
yield `The session transcript has been saved to a markdown file at \`${path}\`.`;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ export const defaultConfig: SerializedContinueConfig = {
|
|||
},
|
||||
{
|
||||
name: "share",
|
||||
description: "Export this session as markdown",
|
||||
description: "Export the current chat session to markdown",
|
||||
params: { ouputDir: "Directory in which to export this session" },
|
||||
},
|
||||
{
|
||||
name: "cmd",
|
||||
|
|
@ -110,7 +111,8 @@ export const defaultConfigJetBrains: SerializedContinueConfig = {
|
|||
},
|
||||
{
|
||||
name: "share",
|
||||
description: "Export this session as markdown",
|
||||
description: "Export the current chat session to markdown",
|
||||
params: { ouputDir: "Directory in which to export this session" },
|
||||
},
|
||||
],
|
||||
customCommands: [
|
||||
|
|
|
|||
|
|
@ -131,7 +131,8 @@ After the "Full example" these examples will only show the relevant portion of t
|
|||
},
|
||||
{
|
||||
"name": "share",
|
||||
"description": "Download and share this session",
|
||||
"description": "Export the current chat session to markdown",
|
||||
"params": { "ouputDir": "Directory in which to export this session" },
|
||||
"step": "ShareSessionStep"
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -43,7 +43,8 @@ Type "/share" to generate a shareable markdown transcript of your current chat h
|
|||
```json
|
||||
{
|
||||
"name": "share",
|
||||
"description": "Download and share this session"
|
||||
"description": "Export the current chat session to markdown",
|
||||
"params": { "ouputDir": "Directory in which to export this session" }
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,8 @@ After the "Full example" these examples will only show the relevant portion of t
|
|||
},
|
||||
{
|
||||
"name": "share",
|
||||
"description": "Download and share this session",
|
||||
"description": "Export the current chat session to markdown",
|
||||
"params": { "ouputDir": "Directory in which to save this session" },
|
||||
"step": "ShareSessionStep"
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ const val DEFAULT_CONFIG = """
|
|||
},
|
||||
{
|
||||
"name": "share",
|
||||
"description": "Download and share this session",
|
||||
"description": "Export the current chat session to markdown",
|
||||
"step": "ShareSessionStep"
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -108,7 +108,8 @@ const initialState: State = {
|
|||
},
|
||||
{
|
||||
name: "share",
|
||||
description: "Download and share this session",
|
||||
description: "Export the current chat session to markdown",
|
||||
params: { ouputDir: "Directory in which to save this session" },
|
||||
},
|
||||
{
|
||||
name: "cmd",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue