Skip to main content

Fs API

The fs module of the @codebolt/plugin-sdk.

import plugin from '@codebolt/plugin-sdk';

Quick Reference

MethodDescription
createFilecreateFile
createFoldercreateFolder
deleteFiledeleteFile
deleteFolderdeleteFolder
editFileWithDiffeditFileWithDiff
fileSearchfileSearch
grepSearchgrepSearch
listCodeDefinitionNameslistCodeDefinitionNames
listDirectorylistDirectory
listFilelistFile
readFilereadFile
readManyFilesreadManyFiles
searchFilessearchFiles
updateFileupdateFile
writeToFilewriteToFile

Methods


createFile

plugin.fs.createFile(fileName: string, source: string, filePath: string): Promise<CreateFileResponse>

createFile

ParameterTypeRequiredDescription
fileNamestringYesThe name of the file to create.
sourcestringYesThe source content to write into the file.
filePathstringYesThe path where the file should be created.

Returns: Promise<CreateFileResponse> — A promise that resolves with the server response.

Full reference →


createFolder

plugin.fs.createFolder(folderName: string, folderPath: string): Promise<CreateFolderResponse>

createFolder

ParameterTypeRequiredDescription
folderNamestringYesThe name of the folder to create.
folderPathstringYesThe path where the folder should be created.

Returns: Promise<CreateFolderResponse> — A promise that resolves with the server response.

Full reference →


deleteFile

plugin.fs.deleteFile(filename: string, filePath: string): Promise<DeleteFileResponse>

deleteFile

ParameterTypeRequiredDescription
filenamestringYesThe name of the file to delete.
filePathstringYesThe path of the file to delete.

Returns: Promise<DeleteFileResponse> — A promise that resolves with the server response.

Full reference →


deleteFolder

plugin.fs.deleteFolder(foldername: string, folderpath: string): Promise<DeleteFolderResponse>

deleteFolder

ParameterTypeRequiredDescription
foldernamestringYesThe name of the folder to delete.
folderpathstringYesThe path of the folder to delete.

Returns: Promise<DeleteFolderResponse> — A promise that resolves with the server response.

Full reference →


editFileWithDiff

plugin.fs.editFileWithDiff(targetFile: string, codeEdit: string, diffIdentifier: string, prompt: string, applyModel?: string): Promise<EditFileAndApplyDiffResponse>

editFileWithDiff

ParameterTypeRequiredDescription
targetFilestringYesThe target file to edit.
codeEditstringYesThe code edit to apply.
diffIdentifierstringYesThe diff identifier.
promptstringYesThe prompt for the edit.
applyModelstringNoThe model to apply the edit with.

Returns: Promise<EditFileAndApplyDiffResponse> — A promise that resolves with the edit result.

Full reference →


fileSearch

plugin.fs.fileSearch(query: string): Promise<FileSearchResponse>

fileSearch

ParameterTypeRequiredDescription
querystringYesThe query to search for.

Returns: Promise<FileSearchResponse> — A promise that resolves with the search results.

Full reference →


grepSearch

plugin.fs.grepSearch(path: string, query: string, includePattern?: string, excludePattern?: string, caseSensitive: boolean): Promise<GrepSearchResponse>

grepSearch

ParameterTypeRequiredDescription
pathstringYesThe path to search within.
querystringYesThe query to search for.
includePatternstringNoPattern of files to include.
excludePatternstringNoPattern of files to exclude.
caseSensitivebooleanYesWhether the search is case sensitive. (default: true)

Returns: Promise<GrepSearchResponse> — A promise that resolves with the search results.

Full reference →


listCodeDefinitionNames

plugin.fs.listCodeDefinitionNames(path: string): Promise<ListCodeDefinitionsResponse>

listCodeDefinitionNames

ParameterTypeRequiredDescription
pathstringYesThe path to search for code definitions.

Returns: Promise<ListCodeDefinitionsResponse> — A promise that resolves with the list of code definition names.

Full reference →


listDirectory

plugin.fs.listDirectory(params: object): Promise<ListDirectoryResponse>

listDirectory

ParameterTypeRequiredDescription
paramsobjectYes

Returns: Promise<ListDirectoryResponse> — A promise that resolves with the directory listing result.

Full reference →


listFile

plugin.fs.listFile(folderPath: string, isRecursive: boolean): Promise<FileListResponse>

listFile

ParameterTypeRequiredDescription
folderPathstringYes
isRecursivebooleanYes(default: false)

Returns: Promise<FileListResponse> — A promise that resolves with the list of files.

Full reference →


readFile

plugin.fs.readFile(filePath: string): Promise<ReadFileResponse>

readFile

ParameterTypeRequiredDescription
filePathstringYesThe path of the file to read.

Returns: Promise<ReadFileResponse> — A promise that resolves with the server response.

Full reference →


readManyFiles

plugin.fs.readManyFiles(params: object): Promise<ReadManyFilesResponse>

readManyFiles

ParameterTypeRequiredDescription
paramsobjectYes

Returns: Promise<ReadManyFilesResponse> — A promise that resolves with the read operation result.

Full reference →


searchFiles

plugin.fs.searchFiles(path: string, regex: string, filePattern: string): Promise<SearchFilesResponse>

searchFiles

ParameterTypeRequiredDescription
pathstringYesThe path to search within.
regexstringYesThe regex pattern to search for.
filePatternstringYesThe file pattern to match files.

Returns: Promise<SearchFilesResponse> — A promise that resolves with the search results.

Full reference →


updateFile

plugin.fs.updateFile(filename: string, filePath: string, newContent: string): Promise<UpdateFileResponse>

updateFile

ParameterTypeRequiredDescription
filenamestringYesThe name of the file to update.
filePathstringYesThe path of the file to update.
newContentstringYesThe new content to write into the file.

Returns: Promise<UpdateFileResponse> — A promise that resolves with the server response.

Full reference →


writeToFile

plugin.fs.writeToFile(relPath: string, newContent: string): Promise<any>

writeToFile

ParameterTypeRequiredDescription
relPathstringYesThe relative path of the file to write to.
newContentstringYesThe new content to write into the file.

Returns: Promise<any> — A promise that resolves with the write operation result.

Full reference →