continue-custom/core/tools/definitions/createNewFile.ts
QiuYang Shen 1c0eaab939 Merge remote-tracking branch 'origin/init-tool-policy-in-tools-definitions' into init-tool-policy-in-tools-definitions
# Conflicts:
#	core/index.d.ts
#	core/tools/definitions/codebaseTool.ts
#	core/tools/definitions/createNewFile.ts
#	core/tools/definitions/createRuleBlock.ts
#	core/tools/definitions/editFile.ts
#	core/tools/definitions/fetchUrlContent.ts
#	core/tools/definitions/globSearch.ts
#	core/tools/definitions/grepSearch.ts
#	core/tools/definitions/ls.ts
#	core/tools/definitions/readCurrentlyOpenFile.ts
#	core/tools/definitions/readFile.ts
#	core/tools/definitions/requestRule.ts
#	core/tools/definitions/runTerminalCommand.ts
#	core/tools/definitions/searchAndReplaceInFile.ts
#	core/tools/definitions/searchWeb.ts
#	core/tools/definitions/viewDiff.ts
#	core/tools/definitions/viewRepoMap.ts
#	core/tools/definitions/viewSubdirectory.ts
2025-07-29 11:34:57 +08:00

43 lines
1.5 KiB
TypeScript

import { Tool } from "../..";
import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn";
import { createSystemMessageExampleCall } from "../systemMessageTools/buildToolsSystemMessage";
export const createNewFileTool: Tool = {
type: "function",
displayTitle: "Create New File",
wouldLikeTo: "create a new file at {{{ filepath }}}",
isCurrently: "creating a new file at {{{ filepath }}}",
hasAlready: "created a new file at {{{ filepath }}}",
group: BUILT_IN_GROUP_NAME,
readonly: false,
isInstant: true,
function: {
name: BuiltInToolNames.CreateNewFile,
description:
"Create a new file. Only use this when a file doesn't exist and should be created",
parameters: {
type: "object",
required: ["filepath", "contents"],
properties: {
filepath: {
type: "string",
description:
"The path where the new file should be created, relative to the root of the workspace",
},
contents: {
type: "string",
description: "The contents to write to the new file",
},
},
},
},
defaultToolPolicy: "allowedWithPermission",
systemMessageDescription: createSystemMessageExampleCall(
BuiltInToolNames.CreateNewFile,
`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:`,
[
["filepath", "path/to/the_file.txt"],
["contents", "Contents of the file"],
],
),
};