@lvce-editor/chat-tool-worker 8.7.0 → 9.0.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 +43 -16
- package/package.json +1 -1
|
@@ -1718,7 +1718,7 @@ const formatXmlMatches = matches => {
|
|
|
1718
1718
|
return lines.join('\n');
|
|
1719
1719
|
};
|
|
1720
1720
|
const formatJsonMatches = matches => {
|
|
1721
|
-
return
|
|
1721
|
+
return {
|
|
1722
1722
|
count: matches.length,
|
|
1723
1723
|
matches: matches.map(match => ({
|
|
1724
1724
|
...(typeof match.lineNumber === 'number' ? {
|
|
@@ -1726,16 +1726,18 @@ const formatJsonMatches = matches => {
|
|
|
1726
1726
|
} : {}),
|
|
1727
1727
|
path: match.path,
|
|
1728
1728
|
text: match.text
|
|
1729
|
-
}))
|
|
1730
|
-
|
|
1729
|
+
})),
|
|
1730
|
+
matchesFound: matches.length > 0
|
|
1731
|
+
};
|
|
1731
1732
|
};
|
|
1732
1733
|
const formatGrepMatches = (matches, outputFormat) => {
|
|
1734
|
+
if (outputFormat === 'json') {
|
|
1735
|
+
return formatJsonMatches(matches);
|
|
1736
|
+
}
|
|
1733
1737
|
if (matches.length === 0) {
|
|
1734
1738
|
return 'No matches found.';
|
|
1735
1739
|
}
|
|
1736
1740
|
switch (outputFormat) {
|
|
1737
|
-
case 'json':
|
|
1738
|
-
return formatJsonMatches(matches);
|
|
1739
1741
|
case 'xml':
|
|
1740
1742
|
return formatXmlMatches(matches);
|
|
1741
1743
|
default:
|
|
@@ -1745,7 +1747,7 @@ const formatGrepMatches = (matches, outputFormat) => {
|
|
|
1745
1747
|
|
|
1746
1748
|
const formatSearchProcessResults = (results, outputFormat) => {
|
|
1747
1749
|
if (!results || results.length === 0) {
|
|
1748
|
-
return
|
|
1750
|
+
return formatGrepMatches([], outputFormat);
|
|
1749
1751
|
}
|
|
1750
1752
|
let currentFile = '';
|
|
1751
1753
|
const matches = [];
|
|
@@ -1771,7 +1773,7 @@ const formatSearchProcessResults = (results, outputFormat) => {
|
|
|
1771
1773
|
}
|
|
1772
1774
|
}
|
|
1773
1775
|
if (matches.length === 0) {
|
|
1774
|
-
return
|
|
1776
|
+
return formatGrepMatches([], outputFormat);
|
|
1775
1777
|
}
|
|
1776
1778
|
return formatGrepMatches(matches, outputFormat);
|
|
1777
1779
|
};
|
|
@@ -1785,16 +1787,23 @@ const isFileUri = value => {
|
|
|
1785
1787
|
return value.startsWith('file://');
|
|
1786
1788
|
};
|
|
1787
1789
|
|
|
1790
|
+
const defaultExcludeGlobs = ['!**/node_modules/**', '!**/.git/**'];
|
|
1788
1791
|
const getRipGrepArgs = ({
|
|
1789
1792
|
includeIgnoredFiles,
|
|
1790
1793
|
includePattern,
|
|
1791
1794
|
isRegexp,
|
|
1792
|
-
query
|
|
1795
|
+
query,
|
|
1796
|
+
useDefaultExcludes
|
|
1793
1797
|
}) => {
|
|
1794
1798
|
const ripGrepArgs = ['--hidden', '--no-require-git', '--smart-case', '--stats', '--json', '--threads', '1', '--ignore-case'];
|
|
1795
1799
|
if (includeIgnoredFiles) {
|
|
1796
1800
|
ripGrepArgs.push('--no-ignore');
|
|
1797
1801
|
}
|
|
1802
|
+
if (useDefaultExcludes) {
|
|
1803
|
+
for (const glob of defaultExcludeGlobs) {
|
|
1804
|
+
ripGrepArgs.push('--glob', glob);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1798
1807
|
if (includePattern && !isFileUri(includePattern) && !isAbsoluteFileSystemPath(includePattern)) {
|
|
1799
1808
|
ripGrepArgs.push('--glob', includePattern);
|
|
1800
1809
|
}
|
|
@@ -1843,8 +1852,11 @@ const executeFileGrepSearch = async (workspaceUri, grepSearchArgs) => {
|
|
|
1843
1852
|
ripGrepArgs: getRipGrepArgs(grepSearchArgs),
|
|
1844
1853
|
searchDir: getSearchDir(workspaceUri, grepSearchArgs.includePattern)
|
|
1845
1854
|
});
|
|
1855
|
+
const formattedResult = formatSearchProcessResults(result.results, grepSearchArgs.outputFormat);
|
|
1846
1856
|
return {
|
|
1847
|
-
|
|
1857
|
+
...(typeof formattedResult === 'string' ? {
|
|
1858
|
+
result: formattedResult
|
|
1859
|
+
} : formattedResult),
|
|
1848
1860
|
...(result.limitHit ? {
|
|
1849
1861
|
warning: 'Search result limit reached.'
|
|
1850
1862
|
} : {})
|
|
@@ -1867,7 +1879,7 @@ const formatLegacyMemorySearchResults = (results, outputFormat) => {
|
|
|
1867
1879
|
}
|
|
1868
1880
|
}
|
|
1869
1881
|
if (matches.length === 0) {
|
|
1870
|
-
return
|
|
1882
|
+
return formatGrepMatches([], outputFormat);
|
|
1871
1883
|
}
|
|
1872
1884
|
return formatGrepMatches(matches, outputFormat);
|
|
1873
1885
|
};
|
|
@@ -1889,16 +1901,22 @@ const executeMemoryGrepSearch = async (workspaceUri, grepSearchArgs, options) =>
|
|
|
1889
1901
|
};
|
|
1890
1902
|
try {
|
|
1891
1903
|
const result = await invoke$1('ExtensionHostTextSearch.textSearchMemory2', searchOptions.scheme, workspaceUri, grepSearchArgs.query, searchOptions, options.assetDir);
|
|
1904
|
+
const formattedResult = formatLegacyMemorySearchResults(result.results || [], grepSearchArgs.outputFormat);
|
|
1892
1905
|
return {
|
|
1893
|
-
|
|
1906
|
+
...(typeof formattedResult === 'string' ? {
|
|
1907
|
+
result: formattedResult
|
|
1908
|
+
} : formattedResult),
|
|
1894
1909
|
...(result.limitHit ? {
|
|
1895
1910
|
warning: 'Search result limit reached.'
|
|
1896
1911
|
} : {})
|
|
1897
1912
|
};
|
|
1898
1913
|
} catch {
|
|
1899
1914
|
const legacyResults = await invoke$1('ExtensionHostTextSearch.textSearchMemory', searchOptions.scheme, workspaceUri, grepSearchArgs.query, searchOptions, options.assetDir);
|
|
1915
|
+
const formattedResult = isLegacyMemorySearchResult(legacyResults) ? formatLegacyMemorySearchResults(legacyResults, grepSearchArgs.outputFormat) : formatLegacyMemorySearchResults([], grepSearchArgs.outputFormat);
|
|
1900
1916
|
return {
|
|
1901
|
-
|
|
1917
|
+
...(typeof formattedResult === 'string' ? {
|
|
1918
|
+
result: formattedResult
|
|
1919
|
+
} : formattedResult)
|
|
1902
1920
|
};
|
|
1903
1921
|
}
|
|
1904
1922
|
};
|
|
@@ -1910,7 +1928,8 @@ const getGrepSearchArgs = args => {
|
|
|
1910
1928
|
isRegexp,
|
|
1911
1929
|
maxResults,
|
|
1912
1930
|
outputFormat,
|
|
1913
|
-
query
|
|
1931
|
+
query,
|
|
1932
|
+
useDefaultExcludes
|
|
1914
1933
|
} = args;
|
|
1915
1934
|
if (typeof query !== 'string' || typeof isRegexp !== 'boolean') {
|
|
1916
1935
|
return undefined;
|
|
@@ -1924,6 +1943,9 @@ const getGrepSearchArgs = args => {
|
|
|
1924
1943
|
if (includeIgnoredFiles !== undefined && typeof includeIgnoredFiles !== 'boolean') {
|
|
1925
1944
|
return undefined;
|
|
1926
1945
|
}
|
|
1946
|
+
if (useDefaultExcludes !== undefined && typeof useDefaultExcludes !== 'boolean') {
|
|
1947
|
+
return undefined;
|
|
1948
|
+
}
|
|
1927
1949
|
if (outputFormat !== undefined && outputFormat !== 'xml' && outputFormat !== 'json') {
|
|
1928
1950
|
return undefined;
|
|
1929
1951
|
}
|
|
@@ -1941,11 +1963,12 @@ const getGrepSearchArgs = args => {
|
|
|
1941
1963
|
outputFormat
|
|
1942
1964
|
}),
|
|
1943
1965
|
isRegexp,
|
|
1944
|
-
query
|
|
1966
|
+
query,
|
|
1967
|
+
useDefaultExcludes: useDefaultExcludes === undefined ? true : useDefaultExcludes
|
|
1945
1968
|
};
|
|
1946
1969
|
};
|
|
1947
1970
|
|
|
1948
|
-
const grepSearchArgumentError = 'Invalid argument: grep_search requires query (string), isRegexp (boolean), optional includePattern (string), optional maxResults (number), optional includeIgnoredFiles (boolean), and optional outputFormat ("xml" | "json").';
|
|
1971
|
+
const grepSearchArgumentError = 'Invalid argument: grep_search requires query (string), isRegexp (boolean), optional includePattern (string), optional maxResults (number), optional includeIgnoredFiles (boolean), optional useDefaultExcludes (boolean), and optional outputFormat ("xml" | "json").';
|
|
1949
1972
|
|
|
1950
1973
|
const executeGrepSearchTool = async (args, options) => {
|
|
1951
1974
|
const grepSearchArgs = getGrepSearchArgs(args);
|
|
@@ -2608,7 +2631,7 @@ const getGlobTool = () => {
|
|
|
2608
2631
|
const getGrepSearchTool = () => {
|
|
2609
2632
|
return {
|
|
2610
2633
|
function: {
|
|
2611
|
-
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
|
|
2634
|
+
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. By default, grep_search also excludes node_modules and .git via ripgrep globs; set useDefaultExcludes to false if you need to search those directories. 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.",
|
|
2612
2635
|
name: 'grep_search',
|
|
2613
2636
|
parameters: {
|
|
2614
2637
|
additionalProperties: false,
|
|
@@ -2637,6 +2660,10 @@ const getGrepSearchTool = () => {
|
|
|
2637
2660
|
query: {
|
|
2638
2661
|
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.",
|
|
2639
2662
|
type: 'string'
|
|
2663
|
+
},
|
|
2664
|
+
useDefaultExcludes: {
|
|
2665
|
+
description: 'Whether to exclude node_modules and .git with built-in ripgrep globs. Defaults to true. Set to false when you explicitly need to search those directories.',
|
|
2666
|
+
type: 'boolean'
|
|
2640
2667
|
}
|
|
2641
2668
|
},
|
|
2642
2669
|
required: ['query', 'isRegexp'],
|