Skip to content

Commit ece5026

Browse files
authored
Merge pull request continuedev#6264 from continuedev/dallin/prompt-tools
Support tools for prompts
2 parents fbcd6b2 + 8113cde commit ece5026

File tree

69 files changed

+1918
-1301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1918
-1301
lines changed

core/commands/index.ts

Lines changed: 0 additions & 88 deletions
This file was deleted.

core/commands/slash/cmd.ts renamed to core/commands/slash/built-in-legacy/cmd.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { streamLines } from "../../diff/util.js";
2-
import { SlashCommand } from "../../index.js";
3-
import { removeQuotesAndEscapes } from "../../util/index.js";
1+
import { streamLines } from "../../../diff/util.js";
2+
import { SlashCommand } from "../../../index.js";
3+
import { removeQuotesAndEscapes } from "../../../util/index.js";
44

55
function commandIsPotentiallyDangerous(command: string) {
66
return (

core/commands/slash/commit.ts renamed to core/commands/slash/built-in-legacy/commit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { SlashCommand } from "../../index.js";
2-
import { renderChatMessage } from "../../util/messageContent.js";
1+
import { SlashCommand } from "../../../index.js";
2+
import { renderChatMessage } from "../../../util/messageContent.js";
33

44
const CommitMessageCommand: SlashCommand = {
55
name: "commit",

core/commands/slash/draftIssue.ts renamed to core/commands/slash/built-in-legacy/draftIssue.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { ChatMessage, SlashCommand } from "../../index.js";
2-
import { removeQuotesAndEscapes } from "../../util/index.js";
3-
import { renderChatMessage } from "../../util/messageContent.js";
1+
import { ChatMessage, SlashCommand } from "../../../index.js";
2+
import { removeQuotesAndEscapes } from "../../../util/index.js";
3+
import { renderChatMessage } from "../../../util/messageContent.js";
44

55
const PROMPT = (
66
input: string,

core/commands/slash/http.ts renamed to core/commands/slash/built-in-legacy/http.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { streamResponse } from "@continuedev/fetch";
2-
import { SlashCommand } from "../../index.js";
3-
import { removeQuotesAndEscapes } from "../../util/index.js";
2+
import { SlashCommand } from "../../../index.js";
3+
import { removeQuotesAndEscapes } from "../../../util/index.js";
44

55
const HttpSlashCommand: SlashCommand = {
66
name: "http",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {
2+
SlashCommand,
3+
SlashCommandDescription,
4+
SlashCommandWithSource,
5+
} from "../../..";
6+
import GenerateTerminalCommand from "./cmd";
7+
import CommitMessageCommand from "./commit";
8+
import DraftIssueCommand from "./draftIssue";
9+
import HttpSlashCommand from "./http";
10+
import OnboardSlashCommand from "./onboard";
11+
import ReviewMessageCommand from "./review";
12+
import ShareSlashCommand from "./share";
13+
14+
const LegacyBuiltInSlashCommands: SlashCommand[] = [
15+
DraftIssueCommand,
16+
ShareSlashCommand,
17+
GenerateTerminalCommand,
18+
HttpSlashCommand,
19+
CommitMessageCommand,
20+
ReviewMessageCommand,
21+
OnboardSlashCommand,
22+
];
23+
24+
export function getLegacyBuiltInSlashCommandFromDescription(
25+
desc: SlashCommandDescription,
26+
): SlashCommandWithSource | undefined {
27+
const cmd = LegacyBuiltInSlashCommands.find((cmd) => cmd.name === desc.name);
28+
if (!cmd) {
29+
return undefined;
30+
}
31+
return {
32+
...cmd,
33+
params: desc.params,
34+
description: desc.description ?? cmd.description,
35+
source: "built-in-legacy",
36+
};
37+
}

core/commands/slash/onboard.ts renamed to core/commands/slash/built-in-legacy/onboard.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import ignore from "ignore";
22

3-
import type { FileType, IDE, SlashCommand } from "../..";
3+
import type { FileType, IDE, SlashCommand } from "../../..";
44
import {
55
DEFAULT_IGNORE,
66
getGlobalContinueIgArray,
77
gitIgArrayFromFile,
8-
} from "../../indexing/ignore";
9-
import { renderChatMessage } from "../../util/messageContent";
8+
} from "../../../indexing/ignore";
9+
import { renderChatMessage } from "../../../util/messageContent";
1010
import {
1111
findUriInDirs,
1212
getUriPathBasename,
1313
joinPathsToUri,
14-
} from "../../util/uri";
14+
} from "../../../util/uri";
1515

1616
const LANGUAGE_DEP_MGMT_FILENAMES = [
1717
"package.json", // JavaScript (Node.js)

core/commands/slash/review.ts renamed to core/commands/slash/built-in-legacy/review.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ChatMessage, SlashCommand } from "../../index.js";
2-
import { renderChatMessage } from "../../util/messageContent.js";
1+
import { ChatMessage, SlashCommand } from "../../../index.js";
2+
import { renderChatMessage } from "../../../util/messageContent.js";
33

44
const prompt = `
55
Review the following code, focusing on Readability, Maintainability, Code Smells, Speed, and Memory Performance. Provide feedback with these guidelines:

core/commands/slash/share.ts renamed to core/commands/slash/built-in-legacy/share.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { homedir } from "node:os";
33
import { fileURLToPath, pathToFileURL } from "node:url";
44
import path from "path";
55

6-
import { languageForFilepath } from "../../autocomplete/constants/AutocompleteLanguageInfo.js";
7-
import { SlashCommand } from "../../index.js";
8-
import { renderChatMessage } from "../../util/messageContent.js";
9-
import { getContinueGlobalPath } from "../../util/paths.js";
6+
import { languageForFilepath } from "../../../autocomplete/constants/AutocompleteLanguageInfo.js";
7+
import { SlashCommand } from "../../../index.js";
8+
import { renderChatMessage } from "../../../util/messageContent.js";
9+
import { getContinueGlobalPath } from "../../../util/paths.js";
1010

1111
// If useful elsewhere, helper funcs should move to core/util/index.ts or similar
1212
function getOffsetDatetime(date: Date): Date {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { CustomCommand, SlashCommandWithSource } from "../..";
2+
3+
export function convertCustomCommandToSlashCommand(
4+
customCommand: CustomCommand,
5+
): SlashCommandWithSource {
6+
const commandName = customCommand.name.startsWith("/")
7+
? customCommand.name.substring(1)
8+
: customCommand.name;
9+
return {
10+
name: commandName,
11+
description: customCommand.description ?? "",
12+
prompt: customCommand.prompt,
13+
source: "json-custom-command",
14+
};
15+
}

0 commit comments

Comments
 (0)