Skip to content

Commit f216ec8

Browse files
authored
Merge pull request #6874 from continuedev/dallin/system-tools-plug-and-play
feat: Plug and play system message tool frameworks
2 parents 8844e2f + ff7b957 commit f216ec8

32 files changed

+378
-444
lines changed

core/index.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,10 @@ export interface Tool {
10931093
faviconUrl?: string;
10941094
group: string;
10951095
originalFunctionName?: string;
1096-
systemMessageDescription?: string;
1096+
systemMessageDescription?: {
1097+
prefix: string;
1098+
exampleArgs?: Array<[string, string | number]>;
1099+
};
10971100
defaultToolPolicy?: ToolPolicy;
10981101
}
10991102

core/tools/definitions/codebaseTool.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Tool } from "../..";
22
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
3-
import { createSystemMessageExampleCall } from "../systemMessageTools/buildToolsSystemMessage";
43

54
export const codebaseTool: Tool = {
65
type: "function",
@@ -28,9 +27,10 @@ export const codebaseTool: Tool = {
2827
},
2928
},
3029
defaultToolPolicy: "allowedWithPermission",
31-
systemMessageDescription: createSystemMessageExampleCall(
32-
BuiltInToolNames.CodebaseTool,
33-
`To search the codebase, use the ${BuiltInToolNames.CodebaseTool} tool with a natural language query. For example, to find authentication logic, you might respond with:`,
34-
[["query", "How is user authentication handled in this codebase?"]],
35-
),
30+
systemMessageDescription: {
31+
prefix: `To search the codebase, use the ${BuiltInToolNames.CodebaseTool} tool with a natural language query. For example, to find authentication logic, you might respond with:`,
32+
exampleArgs: [
33+
["query", "How is user authentication handled in this codebase?"],
34+
],
35+
},
3636
};

core/tools/definitions/createNewFile.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Tool } from "../..";
22
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
3-
import { createSystemMessageExampleCall } from "../systemMessageTools/buildToolsSystemMessage";
43

54
export const createNewFileTool: Tool = {
65
type: "function",
@@ -32,12 +31,11 @@ export const createNewFileTool: Tool = {
3231
},
3332
},
3433
defaultToolPolicy: "allowedWithPermission",
35-
systemMessageDescription: createSystemMessageExampleCall(
36-
BuiltInToolNames.CreateNewFile,
37-
`To create a NEW file, use the ${BuiltInToolNames.CreateNewFile} tool with the relative filepath and new contents. For example, to create a file located at 'path/to/file.txt', you would respond with:`,
38-
[
34+
systemMessageDescription: {
35+
prefix: `To create a NEW file, use the ${BuiltInToolNames.CreateNewFile} tool with the relative filepath and new contents. For example, to create a file located at 'path/to/file.txt', you would respond with:`,
36+
exampleArgs: [
3937
["filepath", "path/to/the_file.txt"],
4038
["contents", "Contents of the file"],
4139
],
42-
),
40+
},
4341
};

core/tools/definitions/createRuleBlock.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Tool } from "../..";
22
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
3-
import { createSystemMessageExampleCall } from "../systemMessageTools/buildToolsSystemMessage";
43

54
const NAME_ARG_DESC =
65
"Short, descriptive name summarizing the rule's purpose (e.g. 'React Standards', 'Type Hints')";
@@ -61,9 +60,8 @@ export const createRuleBlock: Tool = {
6160
},
6261
},
6362
defaultToolPolicy: "allowedWithPermission",
64-
systemMessageDescription: createSystemMessageExampleCall(
65-
BuiltInToolNames.CreateRuleBlock,
66-
`Sometimes the user will provide feedback or guidance on your output. If you were not aware of these "rules", consider using the ${BuiltInToolNames.CreateRuleBlock} tool to persist the rule for future interactions.
63+
systemMessageDescription: {
64+
prefix: `Sometimes the user will provide feedback or guidance on your output. If you were not aware of these "rules", consider using the ${BuiltInToolNames.CreateRuleBlock} tool to persist the rule for future interactions.
6765
This tool cannot be used to edit existing rules, but you can search in the ".continue/rules" folder and use the edit tool to manage rules.
6866
To create a rule, respond with a ${BuiltInToolNames.CreateRuleBlock} tool call and the following arguments:
6967
- name: ${NAME_ARG_DESC}
@@ -72,7 +70,7 @@ To create a rule, respond with a ${BuiltInToolNames.CreateRuleBlock} tool call a
7270
- globs: ${GLOB_ARG_DESC}
7371
- alwaysApply: ${ALWAYS_APPLY_DESC}
7472
For example:`,
75-
[
73+
exampleArgs: [
7674
["name", "Use PropTypes"],
7775
[
7876
"rule",
@@ -85,5 +83,5 @@ For example:`,
8583
["globs", "**/*.js"],
8684
["alwaysApply", "false"],
8785
],
88-
),
86+
},
8987
};

core/tools/definitions/editFile.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Tool } from "../..";
22
import { EDIT_CODE_INSTRUCTIONS } from "../../llm/defaultSystemMessages";
33
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
4-
import { createSystemMessageExampleCall } from "../systemMessageTools/buildToolsSystemMessage";
54
import { NO_PARALLEL_TOOL_CALLING_INSRUCTION } from "./searchAndReplaceInFile";
65

76
export interface EditToolArgs {
@@ -41,19 +40,18 @@ export const editFileTool: Tool = {
4140
},
4241
},
4342
defaultToolPolicy: "allowedWithPermission",
44-
systemMessageDescription: createSystemMessageExampleCall(
45-
BuiltInToolNames.EditExistingFile,
46-
`To edit an EXISTING file, use the ${BuiltInToolNames.EditExistingFile} tool with
43+
systemMessageDescription: {
44+
prefix: `To edit an EXISTING file, use the ${BuiltInToolNames.EditExistingFile} tool with
4745
- filepath: the relative filepath to the file.
4846
- changes: ${CHANGES_DESCRIPTION}
4947
Only use this tool if you already know the contents of the file. Otherwise, use the ${BuiltInToolNames.ReadFile} or ${BuiltInToolNames.ReadCurrentlyOpenFile} tool to read it first.
5048
For example:`,
51-
[
49+
exampleArgs: [
5250
["filepath", "path/to/the_file.ts"],
5351
[
5452
"changes",
5553
"// ... existing code ...\nfunction subtract(a: number, b: number): number {\n return a - b;\n}\n// ... rest of code ...",
5654
],
5755
],
58-
),
56+
},
5957
};

core/tools/definitions/fetchUrlContent.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Tool } from "../..";
22
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
3-
import { createSystemMessageExampleCall } from "../systemMessageTools/buildToolsSystemMessage";
43

54
export const fetchUrlContentTool: Tool = {
65
type: "function",
@@ -27,9 +26,8 @@ export const fetchUrlContentTool: Tool = {
2726
},
2827
},
2928
defaultToolPolicy: "allowedWithPermission",
30-
systemMessageDescription: createSystemMessageExampleCall(
31-
BuiltInToolNames.FetchUrlContent,
32-
`To fetch the content of a URL, use the ${BuiltInToolNames.FetchUrlContent} tool. For example, to read the contents of a webpage, you might respond with:`,
33-
[["url", "https://example.com"]],
34-
),
29+
systemMessageDescription: {
30+
prefix: `To fetch the content of a URL, use the ${BuiltInToolNames.FetchUrlContent} tool. For example, to read the contents of a webpage, you might respond with:`,
31+
exampleArgs: [["url", "https://example.com"]],
32+
},
3533
};

core/tools/definitions/globSearch.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Tool } from "../..";
22
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
3-
import { createSystemMessageExampleCall } from "../systemMessageTools/buildToolsSystemMessage";
43

54
export const globSearchTool: Tool = {
65
type: "function",
@@ -27,9 +26,8 @@ export const globSearchTool: Tool = {
2726
},
2827
},
2928
defaultToolPolicy: "allowedWithoutPermission",
30-
systemMessageDescription: createSystemMessageExampleCall(
31-
BuiltInToolNames.FileGlobSearch,
32-
`To return a list of files based on a glob search pattern, use the ${BuiltInToolNames.FileGlobSearch} tool`,
33-
[["pattern", "*.py"]],
34-
),
29+
systemMessageDescription: {
30+
prefix: `To return a list of files based on a glob search pattern, use the ${BuiltInToolNames.FileGlobSearch} tool`,
31+
exampleArgs: [["pattern", "*.py"]],
32+
},
3533
};

core/tools/definitions/grepSearch.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Tool } from "../..";
22
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
3-
import { createSystemMessageExampleCall } from "../systemMessageTools/buildToolsSystemMessage";
43

54
export const grepSearchTool: Tool = {
65
type: "function",
@@ -28,9 +27,8 @@ export const grepSearchTool: Tool = {
2827
},
2928
},
3029
defaultToolPolicy: "allowedWithoutPermission",
31-
systemMessageDescription: createSystemMessageExampleCall(
32-
BuiltInToolNames.GrepSearch,
33-
`To perform a grep search within the project, call the ${BuiltInToolNames.GrepSearch} tool with the query pattern to match. For example:`,
34-
[["query", ".*main_services.*"]],
35-
),
30+
systemMessageDescription: {
31+
prefix: `To perform a grep search within the project, call the ${BuiltInToolNames.GrepSearch} tool with the query pattern to match. For example:`,
32+
exampleArgs: [["query", ".*main_services.*"]],
33+
},
3634
};

core/tools/definitions/ls.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Tool } from "../..";
22

33
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
4-
import { createSystemMessageExampleCall } from "../systemMessageTools/buildToolsSystemMessage";
54

65
export const lsTool: Tool = {
76
type: "function",
@@ -32,12 +31,11 @@ export const lsTool: Tool = {
3231
},
3332
},
3433
defaultToolPolicy: "allowedWithoutPermission",
35-
systemMessageDescription: createSystemMessageExampleCall(
36-
BuiltInToolNames.LSTool,
37-
`To list files and folders in a given directory, call the ${BuiltInToolNames.LSTool} tool with "dirPath" and "recursive". For example:`,
38-
[
34+
systemMessageDescription: {
35+
prefix: `To list files and folders in a given directory, call the ${BuiltInToolNames.LSTool} tool with "dirPath" and "recursive". For example:`,
36+
exampleArgs: [
3937
["dirPath", "path/to/dir"],
4038
["recursive", "false"],
4139
],
42-
),
40+
},
4341
};

core/tools/definitions/readCurrentlyOpenFile.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Tool } from "../..";
22
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
3-
import { createSystemMessageExampleCall } from "../systemMessageTools/buildToolsSystemMessage";
43

54
export const readCurrentlyOpenFileTool: Tool = {
65
type: "function",
@@ -21,10 +20,8 @@ export const readCurrentlyOpenFileTool: Tool = {
2120
},
2221
},
2322
defaultToolPolicy: "allowedWithPermission",
24-
systemMessageDescription: createSystemMessageExampleCall(
25-
BuiltInToolNames.ReadCurrentlyOpenFile,
26-
`To view the user's currently open file, use the ${BuiltInToolNames.ReadCurrentlyOpenFile} tool.
23+
systemMessageDescription: {
24+
prefix: `To view the user's currently open file, use the ${BuiltInToolNames.ReadCurrentlyOpenFile} tool.
2725
If the user is asking about a file and you don't see any code, use this to check the current file`,
28-
[],
29-
),
26+
},
3027
};

0 commit comments

Comments
 (0)