add source to slash commands, rearrange and mark built in legacy as legacy
This commit is contained in:
parent
75d351a9cf
commit
ff4dcdce73
29 changed files with 168 additions and 138 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { streamLines } from "../../diff/util.js";
|
||||
import { SlashCommand } from "../../index.js";
|
||||
import { removeQuotesAndEscapes } from "../../util/index.js";
|
||||
import { streamLines } from "../../../diff/util.js";
|
||||
import { SlashCommand } from "../../../index.js";
|
||||
import { removeQuotesAndEscapes } from "../../../util/index.js";
|
||||
|
||||
function commandIsPotentiallyDangerous(command: string) {
|
||||
return (
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { SlashCommand } from "../../index.js";
|
||||
import { renderChatMessage } from "../../util/messageContent.js";
|
||||
import { SlashCommand } from "../../../index.js";
|
||||
import { renderChatMessage } from "../../../util/messageContent.js";
|
||||
|
||||
const CommitMessageCommand: SlashCommand = {
|
||||
name: "commit",
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { ChatMessage, SlashCommand } from "../../index.js";
|
||||
import { removeQuotesAndEscapes } from "../../util/index.js";
|
||||
import { renderChatMessage } from "../../util/messageContent.js";
|
||||
import { ChatMessage, SlashCommand } from "../../../index.js";
|
||||
import { removeQuotesAndEscapes } from "../../../util/index.js";
|
||||
import { renderChatMessage } from "../../../util/messageContent.js";
|
||||
|
||||
const PROMPT = (
|
||||
input: string,
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { streamResponse } from "@continuedev/fetch";
|
||||
import { SlashCommand } from "../../index.js";
|
||||
import { removeQuotesAndEscapes } from "../../util/index.js";
|
||||
import { SlashCommand } from "../../../index.js";
|
||||
import { removeQuotesAndEscapes } from "../../../util/index.js";
|
||||
|
||||
const HttpSlashCommand: SlashCommand = {
|
||||
name: "http",
|
||||
37
core/commands/slash/built-in-legacy/index.ts
Normal file
37
core/commands/slash/built-in-legacy/index.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import {
|
||||
SlashCommand,
|
||||
SlashCommandDescription,
|
||||
SlashCommandWithSource,
|
||||
} from "../../..";
|
||||
import GenerateTerminalCommand from "./cmd";
|
||||
import CommitMessageCommand from "./commit";
|
||||
import DraftIssueCommand from "./draftIssue";
|
||||
import HttpSlashCommand from "./http";
|
||||
import OnboardSlashCommand from "./onboard";
|
||||
import ReviewMessageCommand from "./review";
|
||||
import ShareSlashCommand from "./share";
|
||||
|
||||
const LegacyBuiltInSlashCommands: SlashCommand[] = [
|
||||
DraftIssueCommand,
|
||||
ShareSlashCommand,
|
||||
GenerateTerminalCommand,
|
||||
HttpSlashCommand,
|
||||
CommitMessageCommand,
|
||||
ReviewMessageCommand,
|
||||
OnboardSlashCommand,
|
||||
];
|
||||
|
||||
export function getLegacyBuiltInSlashCommandFromDescription(
|
||||
desc: SlashCommandDescription,
|
||||
): SlashCommandWithSource | undefined {
|
||||
const cmd = LegacyBuiltInSlashCommands.find((cmd) => cmd.name === desc.name);
|
||||
if (!cmd) {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
...cmd,
|
||||
params: desc.params,
|
||||
description: desc.description ?? cmd.description,
|
||||
source: "built-in-legacy",
|
||||
};
|
||||
}
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
import ignore from "ignore";
|
||||
|
||||
import type { FileType, IDE, SlashCommand } from "../..";
|
||||
import type { FileType, IDE, SlashCommand } from "../../..";
|
||||
import {
|
||||
DEFAULT_IGNORE,
|
||||
getGlobalContinueIgArray,
|
||||
gitIgArrayFromFile,
|
||||
} from "../../indexing/ignore";
|
||||
import { renderChatMessage } from "../../util/messageContent";
|
||||
} from "../../../indexing/ignore";
|
||||
import { renderChatMessage } from "../../../util/messageContent";
|
||||
import {
|
||||
findUriInDirs,
|
||||
getUriPathBasename,
|
||||
joinPathsToUri,
|
||||
} from "../../util/uri";
|
||||
} from "../../../util/uri";
|
||||
|
||||
const LANGUAGE_DEP_MGMT_FILENAMES = [
|
||||
"package.json", // JavaScript (Node.js)
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { ChatMessage, SlashCommand } from "../../index.js";
|
||||
import { renderChatMessage } from "../../util/messageContent.js";
|
||||
import { ChatMessage, SlashCommand } from "../../../index.js";
|
||||
import { renderChatMessage } from "../../../util/messageContent.js";
|
||||
|
||||
const prompt = `
|
||||
Review the following code, focusing on Readability, Maintainability, Code Smells, Speed, and Memory Performance. Provide feedback with these guidelines:
|
||||
|
|
@ -3,10 +3,10 @@ import { homedir } from "node:os";
|
|||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
import path from "path";
|
||||
|
||||
import { languageForFilepath } from "../../autocomplete/constants/AutocompleteLanguageInfo.js";
|
||||
import { SlashCommand } from "../../index.js";
|
||||
import { renderChatMessage } from "../../util/messageContent.js";
|
||||
import { getContinueGlobalPath } from "../../util/paths.js";
|
||||
import { languageForFilepath } from "../../../autocomplete/constants/AutocompleteLanguageInfo.js";
|
||||
import { SlashCommand } from "../../../index.js";
|
||||
import { renderChatMessage } from "../../../util/messageContent.js";
|
||||
import { getContinueGlobalPath } from "../../../util/paths.js";
|
||||
|
||||
// If useful elsewhere, helper funcs should move to core/util/index.ts or similar
|
||||
function getOffsetDatetime(date: Date): Date {
|
||||
|
|
@ -1,14 +1,12 @@
|
|||
import { CustomCommand, SlashCommand, SlashCommandDescription } from "../";
|
||||
import { renderTemplatedString } from "../promptFiles/v1/renderTemplatedString";
|
||||
import { replaceSlashCommandWithPromptInChatHistory } from "../promptFiles/v1/updateChatHistory";
|
||||
import { renderPromptFileV2 } from "../promptFiles/v2/renderPromptFile";
|
||||
import { renderChatMessage } from "../util/messageContent";
|
||||
import { CustomCommand, SlashCommandWithSource } from "../..";
|
||||
import { renderTemplatedString } from "../../promptFiles/v1/renderTemplatedString";
|
||||
import { replaceSlashCommandWithPromptInChatHistory } from "../../promptFiles/v1/updateChatHistory";
|
||||
import { renderPromptFileV2 } from "../../promptFiles/v2/renderPromptFile";
|
||||
import { renderChatMessage } from "../../util/messageContent";
|
||||
|
||||
import SlashCommands from "./slash";
|
||||
|
||||
export function slashFromCustomCommand(
|
||||
export function convertCustomCommandToSlashCommand(
|
||||
customCommand: CustomCommand,
|
||||
): SlashCommand {
|
||||
): SlashCommandWithSource {
|
||||
const commandName = customCommand.name.startsWith("/")
|
||||
? customCommand.name.substring(1)
|
||||
: customCommand.name;
|
||||
|
|
@ -16,6 +14,7 @@ export function slashFromCustomCommand(
|
|||
name: commandName,
|
||||
description: customCommand.description ?? "",
|
||||
prompt: customCommand.prompt,
|
||||
source: "json-custom-command",
|
||||
run: async function* ({
|
||||
input,
|
||||
llm,
|
||||
|
|
@ -45,8 +44,8 @@ export function slashFromCustomCommand(
|
|||
selectedCode,
|
||||
fetch,
|
||||
fullInput: input,
|
||||
embeddingsProvider: config.modelsByRole.embed[0],
|
||||
reranker: config.modelsByRole.rerank[0],
|
||||
embeddingsProvider: config.selectedModelByRole.embed,
|
||||
reranker: config.selectedModelByRole.rerank,
|
||||
},
|
||||
);
|
||||
|
||||
|
|
@ -72,17 +71,3 @@ export function slashFromCustomCommand(
|
|||
},
|
||||
};
|
||||
}
|
||||
|
||||
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,
|
||||
description: desc.description ?? cmd.description,
|
||||
};
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
import GenerateTerminalCommand from "./cmd";
|
||||
import CommitMessageCommand from "./commit";
|
||||
import DraftIssueCommand from "./draftIssue";
|
||||
import HttpSlashCommand from "./http";
|
||||
import OnboardSlashCommand from "./onboard";
|
||||
import ReviewMessageCommand from "./review";
|
||||
import ShareSlashCommand from "./share";
|
||||
|
||||
export default [
|
||||
DraftIssueCommand,
|
||||
ShareSlashCommand,
|
||||
GenerateTerminalCommand,
|
||||
HttpSlashCommand,
|
||||
CommitMessageCommand,
|
||||
ReviewMessageCommand,
|
||||
OnboardSlashCommand,
|
||||
];
|
||||
|
|
@ -1,17 +1,18 @@
|
|||
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
||||
|
||||
import { PromptMessage } from "@modelcontextprotocol/sdk/types.js";
|
||||
import { ChatMessage, SlashCommand } from "../../index.js";
|
||||
import { ChatMessage, SlashCommandWithSource } from "../../index.js";
|
||||
import { renderChatMessage } from "../../util/messageContent.js";
|
||||
export function constructMcpSlashCommand(
|
||||
client: Client,
|
||||
name: string,
|
||||
description?: string,
|
||||
args?: string[],
|
||||
): SlashCommand {
|
||||
): SlashCommandWithSource {
|
||||
return {
|
||||
name,
|
||||
description: description ?? "MCP Prompt",
|
||||
source: "mcp-prompt",
|
||||
params: {},
|
||||
run: async function* (context) {
|
||||
const argsObject: { [key: string]: string } = {};
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
import { ContinueSDK, SlashCommand } from "../..";
|
||||
import { ContinueSDK, SlashCommandWithSource } from "../..";
|
||||
import { getDiffsFromCache } from "../../autocomplete/snippets/gitDiffCache";
|
||||
import { parsePromptFileV1V2 } from "../../promptFiles/v2/parsePromptFileV1V2";
|
||||
import { renderPromptFileV2 } from "../../promptFiles/v2/renderPromptFile";
|
||||
import { renderChatMessage } from "../../util/messageContent";
|
||||
import { getLastNPathParts } from "../../util/uri";
|
||||
import { parsePromptFileV1V2 } from "../v2/parsePromptFileV1V2";
|
||||
import { renderPromptFileV2 } from "../v2/renderPromptFile";
|
||||
|
||||
import { getContextProviderHelpers } from "./getContextProviderHelpers";
|
||||
import { renderTemplatedString } from "./renderTemplatedString";
|
||||
import { replaceSlashCommandWithPromptInChatHistory } from "./updateChatHistory";
|
||||
import { getContextProviderHelpers } from "../../promptFiles/v1/getContextProviderHelpers";
|
||||
import { renderTemplatedString } from "../../promptFiles/v1/renderTemplatedString";
|
||||
import { replaceSlashCommandWithPromptInChatHistory } from "../../promptFiles/v1/updateChatHistory";
|
||||
|
||||
export function extractName(preamble: { name?: string }, path: string): string {
|
||||
return preamble.name ?? getLastNPathParts(path, 1).split(".prompt")[0];
|
||||
|
|
@ -47,7 +47,7 @@ async function renderPromptV1(
|
|||
export function slashCommandFromPromptFileV1(
|
||||
path: string,
|
||||
content: string,
|
||||
): SlashCommand | null {
|
||||
): SlashCommandWithSource | null {
|
||||
const { name, description, systemMessage, prompt } = parsePromptFileV1V2(
|
||||
path,
|
||||
content,
|
||||
|
|
@ -57,6 +57,7 @@ export function slashCommandFromPromptFileV1(
|
|||
name,
|
||||
description,
|
||||
prompt,
|
||||
source: ".prompt-file",
|
||||
promptFile: path,
|
||||
run: async function* (context) {
|
||||
const [_, renderedPrompt] = await renderPromptFileV2(prompt, {
|
||||
|
|
@ -32,10 +32,9 @@ import {
|
|||
SerializedContinueConfig,
|
||||
SlashCommand,
|
||||
} from "..";
|
||||
import {
|
||||
slashCommandFromDescription,
|
||||
slashFromCustomCommand,
|
||||
} from "../commands/index";
|
||||
import { getLegacyBuiltInSlashCommandFromDescription } from "../commands/slash/built-in-legacy";
|
||||
import { convertCustomCommandToSlashCommand } from "../commands/slash/customSlashCommand";
|
||||
import { slashCommandFromPromptFileV1 } from "../commands/slash/promptFileSlashCommand";
|
||||
import { MCPManagerSingleton } from "../context/mcp/MCPManagerSingleton";
|
||||
import CodebaseContextProvider from "../context/providers/CodebaseContextProvider";
|
||||
import ContinueProxyContextProvider from "../context/providers/ContinueProxyContextProvider";
|
||||
|
|
@ -48,7 +47,6 @@ import { LLMClasses, llmFromDescription } from "../llm/llms";
|
|||
import CustomLLMClass from "../llm/llms/CustomLLM";
|
||||
import { LLMReranker } from "../llm/llms/llm";
|
||||
import TransformersJsEmbeddingsProvider from "../llm/llms/TransformersJsEmbeddingsProvider";
|
||||
import { slashCommandFromPromptFileV1 } from "../promptFiles/v1/slashCommandFromPromptFile";
|
||||
import { getAllPromptFiles } from "../promptFiles/v2/getPromptFiles";
|
||||
import { copyOf } from "../util";
|
||||
import { GlobalContext } from "../util/GlobalContext";
|
||||
|
|
@ -176,13 +174,13 @@ async function serializedToIntermediateConfig(
|
|||
// DEPRECATED - load custom slash commands
|
||||
const slashCommands: SlashCommand[] = [];
|
||||
for (const command of initial.slashCommands || []) {
|
||||
const newCommand = slashCommandFromDescription(command);
|
||||
const newCommand = getLegacyBuiltInSlashCommandFromDescription(command);
|
||||
if (newCommand) {
|
||||
slashCommands.push(newCommand);
|
||||
}
|
||||
}
|
||||
for (const command of initial.customCommands || []) {
|
||||
slashCommands.push(slashFromCustomCommand(command));
|
||||
slashCommands.push(convertCustomCommandToSlashCommand(command));
|
||||
}
|
||||
|
||||
// DEPRECATED - load slash commands from v1 prompt files
|
||||
|
|
@ -529,7 +527,7 @@ async function intermediateToFinalConfig({
|
|||
contextProviders,
|
||||
tools: [...baseToolDefinitions],
|
||||
mcpServerStatuses: [],
|
||||
slashCommands: config.slashCommands ?? [],
|
||||
slashCommands: [],
|
||||
modelsByRole: {
|
||||
chat: models,
|
||||
edit: models,
|
||||
|
|
@ -551,6 +549,17 @@ async function intermediateToFinalConfig({
|
|||
rules: [],
|
||||
};
|
||||
|
||||
for (const cmd of config.slashCommands ?? []) {
|
||||
if ("source" in cmd) {
|
||||
continueConfig.slashCommands.push(cmd);
|
||||
} else {
|
||||
continueConfig.slashCommands.push({
|
||||
...cmd,
|
||||
source: "config-ts-slash-command",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (config.systemMessage) {
|
||||
continueConfig.rules.unshift({
|
||||
rule: config.systemMessage,
|
||||
|
|
@ -651,9 +660,7 @@ async function finalToBrowserConfig(
|
|||
return {
|
||||
allowAnonymousTelemetry: final.allowAnonymousTelemetry,
|
||||
completionOptions: final.completionOptions,
|
||||
slashCommands: final.slashCommands?.map(
|
||||
({ run, ...slashCommandDescription }) => slashCommandDescription,
|
||||
),
|
||||
slashCommands: final.slashCommands?.map(({ run, ...rest }) => rest),
|
||||
contextProviders: final.contextProviders?.map((c) => c.description),
|
||||
disableIndexing: final.disableIndexing,
|
||||
disableSessionTitles: final.disableSessionTitles,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import {
|
|||
SerializedContinueConfig,
|
||||
Tool,
|
||||
} from "../../";
|
||||
import { constructMcpSlashCommand } from "../../commands/slash/mcp";
|
||||
import { constructMcpSlashCommand } from "../../commands/slash/mcpSlashCommand";
|
||||
import { MCPManagerSingleton } from "../../context/mcp/MCPManagerSingleton";
|
||||
import MCPContextProvider from "../../context/providers/MCPContextProvider";
|
||||
import RulesContextProvider from "../../context/providers/RulesContextProvider";
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import {
|
|||
ILLMLogger,
|
||||
RuleWithSource,
|
||||
} from "../..";
|
||||
import { slashFromCustomCommand } from "../../commands";
|
||||
import { slashCommandFromPromptFileV1 } from "../../commands/slash/promptFileSlashCommand";
|
||||
import { MCPManagerSingleton } from "../../context/mcp/MCPManagerSingleton";
|
||||
import CodebaseContextProvider from "../../context/providers/CodebaseContextProvider";
|
||||
import DocsContextProvider from "../../context/providers/DocsContextProvider";
|
||||
|
|
@ -33,11 +33,11 @@ import FileContextProvider from "../../context/providers/FileContextProvider";
|
|||
import { contextProviderClassFromName } from "../../context/providers/index";
|
||||
import { ControlPlaneClient } from "../../control-plane/client";
|
||||
import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider";
|
||||
import { slashCommandFromPromptFileV1 } from "../../promptFiles/v1/slashCommandFromPromptFile";
|
||||
import { getAllPromptFiles } from "../../promptFiles/v2/getPromptFiles";
|
||||
import { GlobalContext } from "../../util/GlobalContext";
|
||||
import { modifyAnyConfigWithSharedConfig } from "../sharedConfig";
|
||||
|
||||
import { convertCustomCommandToSlashCommand } from "../../commands/slash/customSlashCommand";
|
||||
import { getControlPlaneEnvSync } from "../../control-plane/env";
|
||||
import { baseToolDefinitions } from "../../tools";
|
||||
import { getCleanUriPath } from "../../util/uri";
|
||||
|
|
@ -286,7 +286,7 @@ async function configYamlToContinueConfig(options: {
|
|||
|
||||
config.prompts?.forEach((prompt) => {
|
||||
try {
|
||||
const slashCommand = slashFromCustomCommand(prompt);
|
||||
const slashCommand = convertCustomCommandToSlashCommand(prompt);
|
||||
continueConfig.slashCommands?.push(slashCommand);
|
||||
} catch (e) {
|
||||
localErrors.push({
|
||||
|
|
|
|||
35
core/index.d.ts
vendored
35
core/index.d.ts
vendored
|
|
@ -836,15 +836,38 @@ export interface ContinueSDK {
|
|||
abortController: AbortController;
|
||||
}
|
||||
|
||||
export interface SlashCommand {
|
||||
/* Be careful changing SlashCommand or SlashCommandDescription, config.ts can break */
|
||||
export interface SlashCommandDescription {
|
||||
name: string;
|
||||
description: string;
|
||||
prompt?: string;
|
||||
params?: { [key: string]: any };
|
||||
promptFile?: string;
|
||||
}
|
||||
|
||||
export interface SlashCommand extends SlashCommandDescription {
|
||||
run: (sdk: ContinueSDK) => AsyncGenerator<string | undefined>;
|
||||
}
|
||||
|
||||
export type SlashCommandSource =
|
||||
| "built-in-legacy"
|
||||
| "built-in"
|
||||
| "json-custom-command"
|
||||
| "config-ts-slash-command"
|
||||
| "yaml-prompt-block"
|
||||
| "mcp-prompt"
|
||||
| ".prompt-file"
|
||||
| "invokable-rule";
|
||||
|
||||
export interface SlashCommandDescWithSource extends SlashCommandDescription {
|
||||
source: SlashCommandSource;
|
||||
promptFile?: string;
|
||||
}
|
||||
|
||||
export interface SlashCommandWithSource extends SlashCommand {
|
||||
source: SlashCommandSource;
|
||||
promptFile?: string;
|
||||
}
|
||||
|
||||
// Config
|
||||
|
||||
export type StepName =
|
||||
|
|
@ -945,8 +968,6 @@ export interface ContextProviderWithParams {
|
|||
params: { [key: string]: any };
|
||||
}
|
||||
|
||||
export type SlashCommandDescription = Omit<SlashCommand, "run">;
|
||||
|
||||
export interface CustomCommand {
|
||||
name: string;
|
||||
prompt: string;
|
||||
|
|
@ -1442,7 +1463,7 @@ export interface Config {
|
|||
/** Request options that will be applied to all models and context providers */
|
||||
requestOptions?: RequestOptions;
|
||||
/** The list of slash commands that will be available in the sidebar */
|
||||
slashCommands?: SlashCommand[];
|
||||
slashCommands?: (SlashCommand | SlashCommandWithSource)[];
|
||||
/** Each entry in this array will originally be a ContextProviderWithParams, the same object from your config.json, but you may add CustomContextProviders.
|
||||
* A CustomContextProvider requires you only to define a title and getContextItems function. When you type '@title <query>', Continue will call `getContextItems(query)`.
|
||||
*/
|
||||
|
|
@ -1479,7 +1500,7 @@ export interface ContinueConfig {
|
|||
// systemMessage?: string;
|
||||
completionOptions?: BaseCompletionOptions;
|
||||
requestOptions?: RequestOptions;
|
||||
slashCommands: SlashCommand[];
|
||||
slashCommands: SlashCommandWithSource[];
|
||||
contextProviders: IContextProvider[];
|
||||
disableSessionTitles?: boolean;
|
||||
disableIndexing?: boolean;
|
||||
|
|
@ -1502,7 +1523,7 @@ export interface BrowserSerializedContinueConfig {
|
|||
// systemMessage?: string;
|
||||
completionOptions?: BaseCompletionOptions;
|
||||
requestOptions?: RequestOptions;
|
||||
slashCommands: SlashCommandDescription[];
|
||||
slashCommands: SlashCommandDescWithSource[];
|
||||
contextProviders: ContextProviderDescription[];
|
||||
disableIndexing?: boolean;
|
||||
disableSessionTitles?: boolean;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import {
|
|||
Session,
|
||||
SessionMetadata,
|
||||
SiteIndexingConfig,
|
||||
SlashCommandDescription,
|
||||
SlashCommandDescWithSource,
|
||||
StreamDiffLinesPayload,
|
||||
ToolCall,
|
||||
} from "../";
|
||||
|
|
@ -141,7 +141,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
completionOptions: LLMFullCompletionOptions;
|
||||
title: string;
|
||||
legacySlashCommandData?: {
|
||||
command: SlashCommandDescription;
|
||||
command: SlashCommandDescWithSource;
|
||||
input: string;
|
||||
contextItems: ContextItemWithId[];
|
||||
historyIndex: number;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { ChatBubbleLeftIcon } from "@heroicons/react/24/outline";
|
||||
import { SlashCommandDescription } from "core";
|
||||
import { SlashCommandDescWithSource } from "core";
|
||||
|
||||
interface ConversationStarterCardProps {
|
||||
command: SlashCommandDescription;
|
||||
onClick: (command: SlashCommandDescription) => void;
|
||||
command: SlashCommandDescWithSource;
|
||||
onClick: (command: SlashCommandDescWithSource) => void;
|
||||
}
|
||||
|
||||
export function ConversationStarterCard({
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { SlashCommandDescription } from "core";
|
||||
import { SlashCommandDescWithSource } from "core";
|
||||
import { useState } from "react";
|
||||
import { useBookmarkedSlashCommands } from "../../hooks/useBookmarkedSlashCommands";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
|
|
@ -23,7 +23,7 @@ export function ConversationStarterCards() {
|
|||
isCommandBookmarked(command.name),
|
||||
);
|
||||
|
||||
function onClick(command: SlashCommandDescription) {
|
||||
function onClick(command: SlashCommandDescWithSource) {
|
||||
mainEditor?.commands.insertPrompt(command);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +1,31 @@
|
|||
import { SlashCommandDescription } from "core";
|
||||
import { SlashCommandDescWithSource } from "core";
|
||||
import { sortCommandsByBookmarkStatus } from "../utils";
|
||||
|
||||
describe("sortCommandsByBookmarkStatus", () => {
|
||||
const mockCommands: SlashCommandDescription[] = [
|
||||
const mockCommands: SlashCommandDescWithSource[] = [
|
||||
{
|
||||
name: "command1",
|
||||
description: "First command",
|
||||
prompt: "This is command 1",
|
||||
source: "built-in",
|
||||
},
|
||||
{
|
||||
name: "command2",
|
||||
description: "Second command",
|
||||
prompt: "This is command 2",
|
||||
source: "built-in",
|
||||
},
|
||||
{
|
||||
name: "command3",
|
||||
description: "Third command",
|
||||
prompt: "This is command 3",
|
||||
source: "built-in",
|
||||
},
|
||||
{
|
||||
name: "command4",
|
||||
description: "Fourth command",
|
||||
prompt: "This is command 4",
|
||||
source: "built-in",
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { SlashCommandDescription } from "core";
|
||||
import { SlashCommandDescWithSource } from "core";
|
||||
import {} from "core/config/default";
|
||||
|
||||
/**
|
||||
|
|
@ -8,9 +8,9 @@ import {} from "core/config/default";
|
|||
* @returns A new sorted array with bookmarked commands first
|
||||
*/
|
||||
export function sortCommandsByBookmarkStatus(
|
||||
commands: SlashCommandDescription[],
|
||||
commands: SlashCommandDescWithSource[],
|
||||
bookmarkedCommands: string[],
|
||||
): SlashCommandDescription[] {
|
||||
): SlashCommandDescWithSource[] {
|
||||
return [...commands].sort((a, b) => {
|
||||
const aIsBookmarked = bookmarkedCommands.includes(a.name);
|
||||
const bIsBookmarked = bookmarkedCommands.includes(b.name);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import {
|
|||
PencilIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { BookmarkIcon as BookmarkSolid } from "@heroicons/react/24/solid";
|
||||
import { SlashCommandDescription } from "core";
|
||||
import { SlashCommandDescWithSource } from "core";
|
||||
import { useContext, useMemo } from "react";
|
||||
import { useAuth } from "../../../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../../../context/IdeMessenger";
|
||||
|
|
@ -15,7 +15,7 @@ import { useMainEditor } from "../../TipTapEditor";
|
|||
import { useLump } from "../LumpContext";
|
||||
import { ExploreBlocksButton } from "./ExploreBlocksButton";
|
||||
|
||||
type PromptWithSlug = SlashCommandDescription & { slug?: string };
|
||||
type PromptWithSlug = SlashCommandDescWithSource & { slug?: string };
|
||||
|
||||
interface PromptRowProps {
|
||||
prompt: PromptWithSlug;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { mergeAttributes, Node } from "@tiptap/core";
|
||||
import { Node as ProseMirrorNode } from "@tiptap/pm/model";
|
||||
import { ReactNodeViewRenderer } from "@tiptap/react";
|
||||
import { ContextItemWithId, SlashCommandDescription } from "core";
|
||||
import { ContextItemWithId, SlashCommandDescWithSource } from "core";
|
||||
import { MAIN_EDITOR_INPUT_ID } from "../../../../../pages/gui/Chat";
|
||||
import { PromptBlockPreview } from "./PromptBlockPreview";
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ declare module "@tiptap/core" {
|
|||
/**
|
||||
* Insert a prompt block into the editor
|
||||
*/
|
||||
insertPrompt: (item: SlashCommandDescription) => ReturnType;
|
||||
insertPrompt: (item: SlashCommandDescWithSource) => ReturnType;
|
||||
|
||||
/**
|
||||
* Clear all prompt blocks from the editor
|
||||
|
|
@ -76,7 +76,7 @@ export const PromptBlock = Node.create<PromptBlockOptions>({
|
|||
addCommands() {
|
||||
return {
|
||||
insertPrompt:
|
||||
(prompt: SlashCommandDescription) =>
|
||||
(prompt: SlashCommandDescWithSource) =>
|
||||
({ chain }) => {
|
||||
const item: ContextItemWithId = {
|
||||
content: prompt.prompt ?? "",
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {
|
|||
MessageContent,
|
||||
MessagePart,
|
||||
RangeInFile,
|
||||
SlashCommandDescription,
|
||||
SlashCommandDescWithSource,
|
||||
TextMessagePart,
|
||||
} from "core";
|
||||
import { ctxItemToRifWithContents } from "core/commands/util";
|
||||
|
|
@ -32,7 +32,7 @@ interface ResolveEditorContentInput {
|
|||
modifiers: InputModifiers;
|
||||
ideMessenger: IIdeMessenger;
|
||||
defaultContextProviders: DefaultContextProvider[];
|
||||
availableSlashCommands: SlashCommandDescription[];
|
||||
availableSlashCommands: SlashCommandDescWithSource[];
|
||||
dispatch: Dispatch;
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ type ResolveEditorContentOutput = [
|
|||
MessageContent,
|
||||
(
|
||||
| {
|
||||
command: SlashCommandDescription;
|
||||
command: SlashCommandDescWithSource;
|
||||
input: string;
|
||||
}
|
||||
| undefined
|
||||
|
|
@ -184,9 +184,9 @@ function processEditorContent(editorState: JSONContent) {
|
|||
*/
|
||||
function processSlashCommand(
|
||||
slashCommandName: string | undefined,
|
||||
availableSlashCommands: SlashCommandDescription[],
|
||||
availableSlashCommands: SlashCommandDescWithSource[],
|
||||
parts: MessagePart[],
|
||||
): { command: SlashCommandDescription; input: string } | undefined {
|
||||
): { command: SlashCommandDescWithSource; input: string } | undefined {
|
||||
if (!slashCommandName) return;
|
||||
|
||||
const command = availableSlashCommands.find(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { SlashCommandDescription } from "core";
|
||||
import { SlashCommandDescWithSource } from "core";
|
||||
import { usePostHog } from "posthog-js/react";
|
||||
|
||||
import { useAppDispatch, useAppSelector } from "../redux/hooks";
|
||||
|
|
@ -17,7 +17,7 @@ export function useBookmarkedSlashCommands() {
|
|||
return bookmarkedCommands.includes(commandName);
|
||||
};
|
||||
|
||||
const toggleBookmark = (command: SlashCommandDescription) => {
|
||||
const toggleBookmark = (command: SlashCommandDescWithSource) => {
|
||||
const isBookmarked = isCommandBookmarked(command.name);
|
||||
|
||||
posthog.capture("toggle_bookmarked_slash_command", {
|
||||
|
|
|
|||
|
|
@ -9,16 +9,7 @@ export type ConfigState = {
|
|||
};
|
||||
|
||||
export const EMPTY_CONFIG: BrowserSerializedContinueConfig = {
|
||||
slashCommands: [
|
||||
{
|
||||
name: "share",
|
||||
description: "Export the current chat session to markdown",
|
||||
},
|
||||
{
|
||||
name: "cmd",
|
||||
description: "Generate a shell command",
|
||||
},
|
||||
],
|
||||
slashCommands: [],
|
||||
contextProviders: [],
|
||||
tools: [],
|
||||
mcpServerStatuses: [],
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
import { SlashCommandDescription } from "core";
|
||||
import { SlashCommandDescWithSource } from "core";
|
||||
import { SerializedOrgWithProfiles } from "core/config/ProfileLifecycleManager";
|
||||
|
||||
const DEFAULT_SLASH_COMMANDS_BOOKMARKS_COUNT = 5;
|
||||
|
|
@ -81,7 +81,7 @@ export const profilesSlice = createSlice({
|
|||
state,
|
||||
action: PayloadAction<{
|
||||
profileId: string;
|
||||
defaultSlashCommands?: SlashCommandDescription[];
|
||||
defaultSlashCommands?: SlashCommandDescWithSource[];
|
||||
}>,
|
||||
) => {
|
||||
const { profileId, defaultSlashCommands = [] } = action.payload;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export const gatherContext = createAsyncThunk<
|
|||
selectedContextItems: ContextItemWithId[];
|
||||
selectedCode: RangeInFile[];
|
||||
content: MessageContent;
|
||||
slashCommandWithInput:
|
||||
legacyCommandWithInput:
|
||||
| {
|
||||
command: SlashCommandDescription;
|
||||
input: string;
|
||||
|
|
@ -50,7 +50,7 @@ export const gatherContext = createAsyncThunk<
|
|||
}
|
||||
|
||||
// Resolve context providers and construct new history
|
||||
let [selectedContextItems, selectedCode, content, slashCommandWithInput] =
|
||||
let [selectedContextItems, selectedCode, content, legacyCommandWithInput] =
|
||||
await resolveEditorContent({
|
||||
editorState,
|
||||
modifiers,
|
||||
|
|
@ -118,7 +118,7 @@ export const gatherContext = createAsyncThunk<
|
|||
selectedContextItems,
|
||||
selectedCode,
|
||||
content,
|
||||
slashCommandWithInput,
|
||||
legacyCommandWithInput,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ export const streamResponseThunk = createAsyncThunk<
|
|||
selectedContextItems,
|
||||
selectedCode,
|
||||
content,
|
||||
slashCommandWithInput,
|
||||
legacyCommandWithInput,
|
||||
} = unwrapResult(result);
|
||||
|
||||
// symbols for both context items AND selected codeblocks
|
||||
|
|
@ -133,9 +133,9 @@ export const streamResponseThunk = createAsyncThunk<
|
|||
});
|
||||
posthog.capture("userInput", {});
|
||||
|
||||
if (slashCommandWithInput) {
|
||||
if (legacyCommandWithInput) {
|
||||
posthog.capture("step run", {
|
||||
step_name: slashCommandWithInput.command.name,
|
||||
step_name: legacyCommandWithInput.command.name,
|
||||
params: {},
|
||||
});
|
||||
}
|
||||
|
|
@ -144,12 +144,12 @@ export const streamResponseThunk = createAsyncThunk<
|
|||
await dispatch(
|
||||
streamNormalInput({
|
||||
messages,
|
||||
legacySlashCommandData: slashCommandWithInput
|
||||
legacySlashCommandData: legacyCommandWithInput
|
||||
? {
|
||||
command: slashCommandWithInput.command,
|
||||
command: legacyCommandWithInput.command,
|
||||
contextItems: selectedContextItems,
|
||||
historyIndex: inputIndex,
|
||||
input: slashCommandWithInput.input,
|
||||
input: legacyCommandWithInput.input,
|
||||
selectedCode,
|
||||
}
|
||||
: undefined,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue