@lvce-editor/chat-tool-worker 7.9.0 → 7.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chatToolWorkerMain.js +157 -48
- package/package.json +1 -1
|
@@ -1093,6 +1093,67 @@ const executeGetWorkspaceUriTool = async (_args, _options) => {
|
|
|
1093
1093
|
}
|
|
1094
1094
|
};
|
|
1095
1095
|
|
|
1096
|
+
const executeGlobTool = async (args, _options) => {
|
|
1097
|
+
const pattern = typeof args.pattern === 'string' ? args.pattern : '';
|
|
1098
|
+
if (!pattern) {
|
|
1099
|
+
return {
|
|
1100
|
+
error: 'Invalid argument: pattern must be a non-empty string.'
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
const paths = ['./src/main.ts', './src/utils/search.ts', './test/Main.test.ts'];
|
|
1104
|
+
return {
|
|
1105
|
+
paths,
|
|
1106
|
+
pattern
|
|
1107
|
+
};
|
|
1108
|
+
};
|
|
1109
|
+
|
|
1110
|
+
const getGrepSearchArgs = args => {
|
|
1111
|
+
const {
|
|
1112
|
+
includeIgnoredFiles,
|
|
1113
|
+
includePattern,
|
|
1114
|
+
isRegexp,
|
|
1115
|
+
maxResults,
|
|
1116
|
+
query
|
|
1117
|
+
} = args;
|
|
1118
|
+
if (typeof query !== 'string' || typeof isRegexp !== 'boolean') {
|
|
1119
|
+
return undefined;
|
|
1120
|
+
}
|
|
1121
|
+
if (includePattern !== undefined && typeof includePattern !== 'string') {
|
|
1122
|
+
return undefined;
|
|
1123
|
+
}
|
|
1124
|
+
if (maxResults !== undefined && typeof maxResults !== 'number') {
|
|
1125
|
+
return undefined;
|
|
1126
|
+
}
|
|
1127
|
+
if (includeIgnoredFiles !== undefined && typeof includeIgnoredFiles !== 'boolean') {
|
|
1128
|
+
return undefined;
|
|
1129
|
+
}
|
|
1130
|
+
return {
|
|
1131
|
+
...(includeIgnoredFiles === undefined ? {} : {
|
|
1132
|
+
includeIgnoredFiles
|
|
1133
|
+
}),
|
|
1134
|
+
...(includePattern === undefined ? {} : {
|
|
1135
|
+
includePattern
|
|
1136
|
+
}),
|
|
1137
|
+
...(maxResults === undefined ? {} : {
|
|
1138
|
+
maxResults
|
|
1139
|
+
}),
|
|
1140
|
+
isRegexp,
|
|
1141
|
+
query
|
|
1142
|
+
};
|
|
1143
|
+
};
|
|
1144
|
+
const executeGrepSearchTool = async (args, _options) => {
|
|
1145
|
+
const grepSearchArgs = getGrepSearchArgs(args);
|
|
1146
|
+
if (!grepSearchArgs) {
|
|
1147
|
+
return {
|
|
1148
|
+
error: 'Invalid argument: grep_search requires query (string), isRegexp (boolean), optional includePattern (string), optional maxResults (number), and optional includeIgnoredFiles (boolean).'
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
return {
|
|
1152
|
+
arguments: grepSearchArgs,
|
|
1153
|
+
result: 'No matches found.'
|
|
1154
|
+
};
|
|
1155
|
+
};
|
|
1156
|
+
|
|
1096
1157
|
const executeListFilesTool = async (args, _options) => {
|
|
1097
1158
|
const uri = typeof args.uri === 'string' ? args.uri : '';
|
|
1098
1159
|
if (!uri || !isAbsoluteUri(uri)) {
|
|
@@ -1515,54 +1576,46 @@ const parseToolArguments = rawArguments => {
|
|
|
1515
1576
|
|
|
1516
1577
|
const executeChatTool = async (name, rawArguments, options) => {
|
|
1517
1578
|
const args = parseToolArguments(rawArguments);
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
if (name === 'create_directory') {
|
|
1558
|
-
return executeCreateDirectoryTool(args);
|
|
1559
|
-
}
|
|
1560
|
-
if (name === 'update_todo') {
|
|
1561
|
-
return executeUpdateTodoTool(args);
|
|
1579
|
+
switch (name) {
|
|
1580
|
+
case 'close_preview':
|
|
1581
|
+
return executeClosePreviewTool();
|
|
1582
|
+
case 'create_directory':
|
|
1583
|
+
return executeCreateDirectoryTool(args);
|
|
1584
|
+
case 'edit_file':
|
|
1585
|
+
return executeEditFileTool(args);
|
|
1586
|
+
case 'getWorkspaceUri':
|
|
1587
|
+
return executeGetWorkspaceUriTool();
|
|
1588
|
+
case 'glob':
|
|
1589
|
+
return executeGlobTool(args);
|
|
1590
|
+
case 'grep_search':
|
|
1591
|
+
return executeGrepSearchTool(args);
|
|
1592
|
+
case 'list_files':
|
|
1593
|
+
return executeListFilesTool(args);
|
|
1594
|
+
case 'open_preview':
|
|
1595
|
+
return executeOpenPreviewTool(args);
|
|
1596
|
+
case 'openEditor':
|
|
1597
|
+
return executeOpenEditorTool(args);
|
|
1598
|
+
case 'read_file':
|
|
1599
|
+
return executeReadFileTool(args);
|
|
1600
|
+
case 'rename':
|
|
1601
|
+
return executeRenameTool(args);
|
|
1602
|
+
case 'render_html':
|
|
1603
|
+
return executeRenderHtmlTool(args);
|
|
1604
|
+
case 'rg':
|
|
1605
|
+
return executeRgTool(args);
|
|
1606
|
+
case 'run_in_terminal':
|
|
1607
|
+
return executeRunInTerminalTool(args);
|
|
1608
|
+
case 'search_text':
|
|
1609
|
+
return executeSearchTextTool(args);
|
|
1610
|
+
case 'update_todo':
|
|
1611
|
+
return executeUpdateTodoTool(args);
|
|
1612
|
+
case 'write_file':
|
|
1613
|
+
return executeWriteFileTool(args);
|
|
1614
|
+
default:
|
|
1615
|
+
return {
|
|
1616
|
+
error: `Unknown tool: ${name}`
|
|
1617
|
+
};
|
|
1562
1618
|
}
|
|
1563
|
-
return {
|
|
1564
|
-
error: `Unknown tool: ${name}`
|
|
1565
|
-
};
|
|
1566
1619
|
};
|
|
1567
1620
|
|
|
1568
1621
|
const getReadFileTool = () => {
|
|
@@ -1855,6 +1908,42 @@ const getRgTool = () => {
|
|
|
1855
1908
|
type: 'function'
|
|
1856
1909
|
};
|
|
1857
1910
|
};
|
|
1911
|
+
const getGrepSearchTool = () => {
|
|
1912
|
+
return {
|
|
1913
|
+
function: {
|
|
1914
|
+
description: "Do a fast text search in the workspace. Use this tool when you want to search with an exact string or regex. If you are not sure what words will appear in the workspace, prefer using regex patterns with alternation (|) or character classes to search for multiple potential words at once instead of making separate searches. For example, use 'function|method|procedure' to look for all of those words at once. Use includePattern to search within files matching a specific pattern, or in a specific file, using a relative path. Use 'includeIgnoredFiles' to include files normally ignored by .gitignore, other ignore files, and `files.exclude` and `search.exclude` settings. Warning: using this may cause the search to be slower, only set it when you want to search in ignored folders like node_modules or build outputs. Use this tool when you want to see an overview of a particular file, instead of using read_file many times to look for code within a file.\n\nIn a multi-root workspace, you can scope the search to a specific workspace folder by using the absolute path to the folder as the includePattern, e.g. /path/to/folder.",
|
|
1915
|
+
name: 'grep_search',
|
|
1916
|
+
parameters: {
|
|
1917
|
+
additionalProperties: false,
|
|
1918
|
+
properties: {
|
|
1919
|
+
includeIgnoredFiles: {
|
|
1920
|
+
description: 'Whether to include files that would normally be ignored according to .gitignore, other ignore files and `files.exclude` and `search.exclude` settings. Warning: using this may cause the search to be slower. Only set it when you want to search in ignored folders like node_modules or build outputs.',
|
|
1921
|
+
type: 'boolean'
|
|
1922
|
+
},
|
|
1923
|
+
includePattern: {
|
|
1924
|
+
description: 'Search files matching this glob pattern. Will be applied to the relative path of files within the workspace. To search recursively inside a folder, use a proper glob pattern like "src/folder/**". Do not use | in includePattern. Can also be an absolute path to a workspace folder to scope the search in a multi-root workspace.',
|
|
1925
|
+
type: 'string'
|
|
1926
|
+
},
|
|
1927
|
+
isRegexp: {
|
|
1928
|
+
description: 'Whether the pattern is a regex.',
|
|
1929
|
+
type: 'boolean'
|
|
1930
|
+
},
|
|
1931
|
+
maxResults: {
|
|
1932
|
+
description: "The maximum number of results to return. Do not use this unless necessary, it can slow things down. By default, only some matches are returned. If you use this and don't see what you're looking for, you can try again with a more specific query or a larger maxResults.",
|
|
1933
|
+
type: 'number'
|
|
1934
|
+
},
|
|
1935
|
+
query: {
|
|
1936
|
+
description: "The pattern to search for in files in the workspace. Use regex with alternation (e.g., 'word1|word2|word3') or character classes to find multiple potential words in a single search. Be sure to set the isRegexp property properly to declare whether it's a regex or plain text pattern. Is case-insensitive.",
|
|
1937
|
+
type: 'string'
|
|
1938
|
+
}
|
|
1939
|
+
},
|
|
1940
|
+
required: ['query', 'isRegexp'],
|
|
1941
|
+
type: 'object'
|
|
1942
|
+
}
|
|
1943
|
+
},
|
|
1944
|
+
type: 'function'
|
|
1945
|
+
};
|
|
1946
|
+
};
|
|
1858
1947
|
const getRunInTerminalTool = () => {
|
|
1859
1948
|
return {
|
|
1860
1949
|
function: {
|
|
@@ -1904,6 +1993,26 @@ const getCreateDirectoryTool = () => {
|
|
|
1904
1993
|
type: 'function'
|
|
1905
1994
|
};
|
|
1906
1995
|
};
|
|
1996
|
+
const getGlobTool = () => {
|
|
1997
|
+
return {
|
|
1998
|
+
function: {
|
|
1999
|
+
description: 'Find files by glob pattern and return matching relative paths.',
|
|
2000
|
+
name: 'glob',
|
|
2001
|
+
parameters: {
|
|
2002
|
+
additionalProperties: false,
|
|
2003
|
+
properties: {
|
|
2004
|
+
pattern: {
|
|
2005
|
+
description: 'Glob pattern to match files, for example `packages/e2e/src/*.ts`.',
|
|
2006
|
+
type: 'string'
|
|
2007
|
+
}
|
|
2008
|
+
},
|
|
2009
|
+
required: ['pattern'],
|
|
2010
|
+
type: 'object'
|
|
2011
|
+
}
|
|
2012
|
+
},
|
|
2013
|
+
type: 'function'
|
|
2014
|
+
};
|
|
2015
|
+
};
|
|
1907
2016
|
const getUpdateTodoTool = () => {
|
|
1908
2017
|
return {
|
|
1909
2018
|
function: {
|
|
@@ -1925,7 +2034,7 @@ const getUpdateTodoTool = () => {
|
|
|
1925
2034
|
};
|
|
1926
2035
|
};
|
|
1927
2036
|
const getBasicChatTools = () => {
|
|
1928
|
-
return [getReadFileTool(), getWriteFileTool(), getRenameTool(), getEditFileTool(), getListFilesTool(), getGetWorkspaceUriTool(), getRenderHtmlTool(), getOpenPreviewTool(), getOpenEditorTool(), getClosePreviewTool(), getSearchTextTool(), getRgTool(), getRunInTerminalTool(), getCreateDirectoryTool(), getUpdateTodoTool()];
|
|
2037
|
+
return [getReadFileTool(), getWriteFileTool(), getRenameTool(), getEditFileTool(), getListFilesTool(), getGetWorkspaceUriTool(), getRenderHtmlTool(), getOpenPreviewTool(), getOpenEditorTool(), getClosePreviewTool(), getSearchTextTool(), getRgTool(), getGrepSearchTool(), getRunInTerminalTool(), getCreateDirectoryTool(), getGlobTool(), getUpdateTodoTool()];
|
|
1929
2038
|
};
|
|
1930
2039
|
|
|
1931
2040
|
const handleMessagePort = async port => {
|