✨ comment slash command
This commit is contained in:
parent
8379a92df0
commit
59dbf7c885
7 changed files with 39159 additions and 7 deletions
|
|
@ -9,13 +9,14 @@ export interface ContinueSDK {
|
|||
addContextItem: (item: ContextItem) => void;
|
||||
history: ChatMessage[];
|
||||
input: string;
|
||||
options?: any;
|
||||
params?: any;
|
||||
contextItems: ContextItem[];
|
||||
}
|
||||
|
||||
export interface SlashCommand {
|
||||
name: string;
|
||||
description: string;
|
||||
params?: { [key: string]: any };
|
||||
run: (sdk: ContinueSDK) => AsyncGenerator<string | undefined>;
|
||||
}
|
||||
|
||||
|
|
@ -46,6 +47,15 @@ export function slashFromCustomCommand(
|
|||
};
|
||||
}
|
||||
|
||||
export function slashCommandFromDescription(desc: SlashCommandDescription) {
|
||||
return SlashCommands.find((cmd) => cmd.name === desc.name);
|
||||
export function slashCommandFromDescription(
|
||||
desc: SlashCommandDescription
|
||||
): SlashCommand | undefined {
|
||||
const cmd = SlashCommands.find((cmd) => cmd.name === desc.name);
|
||||
if (!cmd) {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
...cmd,
|
||||
params: desc.params,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
17
core/commands/slash/comment.ts
Normal file
17
core/commands/slash/comment.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { SlashCommand } from "..";
|
||||
import EditSlashCommand from "./edit";
|
||||
|
||||
const CommentSlashCommand: SlashCommand = {
|
||||
name: "comment",
|
||||
description: "Write comments for highlighted code",
|
||||
run: async function* (sdk) {
|
||||
for await (const update of EditSlashCommand.run({
|
||||
...sdk,
|
||||
input: "Write comments for this code",
|
||||
})) {
|
||||
yield update;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default CommentSlashCommand;
|
||||
|
|
@ -24,8 +24,8 @@ Body:\n\n`;
|
|||
const DraftIssueCommand: SlashCommand = {
|
||||
name: "issue",
|
||||
description: "Draft a GitHub issue",
|
||||
run: async function* ({ input, llm, history, options }) {
|
||||
if (options?.repositoryUrl === undefined) {
|
||||
run: async function* ({ input, llm, history, params }) {
|
||||
if (params?.repositoryUrl === undefined) {
|
||||
yield "This command requires a repository URL to be set in the config file.";
|
||||
return;
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ const DraftIssueCommand: SlashCommand = {
|
|||
}
|
||||
|
||||
// const url = f"{self.repository_url}/issues/new?title={quote(title)}&body={quote(body)}"
|
||||
const url = `${options.repositoryUrl}/issues/new?title={encodeURIComponent(title)}&body={encodeURIComponent(body)}`;
|
||||
const url = `${params.repositoryUrl}/issues/new?title={encodeURIComponent(title)}&body={encodeURIComponent(body)}`;
|
||||
yield `\n\n[Link to draft of issue](${url})`;
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import GenerateTerminalCommand from "./cmd";
|
||||
import CommentSlashCommand from "./comment";
|
||||
import DraftIssueCommand from "./draftIssue";
|
||||
import EditSlashCommand from "./edit";
|
||||
import ShareSlashCommand from "./share";
|
||||
|
|
@ -10,4 +11,5 @@ export default [
|
|||
StackOverflowSlashCommand,
|
||||
GenerateTerminalCommand,
|
||||
EditSlashCommand,
|
||||
CommentSlashCommand,
|
||||
];
|
||||
|
|
|
|||
6
core/config/config.ts
Normal file
6
core/config/config.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { ContinueConfig } from ".";
|
||||
|
||||
function modifyConfig(config: ContinueConfig): ContinueConfig {
|
||||
config.allowAnonymousTelemetry = false;
|
||||
return config;
|
||||
}
|
||||
39117
core/config/tsc.js
Normal file
39117
core/config/tsc.js
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -81,7 +81,7 @@ function useChatHandler(dispatch: Dispatch) {
|
|||
dispatch(addContextItems([item]));
|
||||
},
|
||||
contextItems,
|
||||
options: {}, // TODO: pass options to slash command
|
||||
params: slashCommand.params,
|
||||
};
|
||||
|
||||
// TODO: if the model returned fast enough it would immediately break
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue