@lvce-editor/chat-tool-worker 7.13.0 → 8.1.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 +62 -13
- package/package.json +1 -1
|
@@ -1127,6 +1127,10 @@ const create = rpcId => {
|
|
|
1127
1127
|
};
|
|
1128
1128
|
};
|
|
1129
1129
|
|
|
1130
|
+
const Directory = 3;
|
|
1131
|
+
const File = 7;
|
|
1132
|
+
const Symlink = 9;
|
|
1133
|
+
|
|
1130
1134
|
const ChatStorageWorker = 6003;
|
|
1131
1135
|
const FileSystemWorker = 209;
|
|
1132
1136
|
const RendererWorker = 1;
|
|
@@ -1136,8 +1140,12 @@ const {
|
|
|
1136
1140
|
} = create(ChatStorageWorker);
|
|
1137
1141
|
|
|
1138
1142
|
const {
|
|
1143
|
+
invoke: invoke$1,
|
|
1139
1144
|
set: set$1
|
|
1140
1145
|
} = create(FileSystemWorker);
|
|
1146
|
+
const readDirWithFileTypes = async uri => {
|
|
1147
|
+
return invoke$1('FileSystem.readDirWithFileTypes', uri);
|
|
1148
|
+
};
|
|
1141
1149
|
|
|
1142
1150
|
const {
|
|
1143
1151
|
invoke,
|
|
@@ -1416,21 +1424,25 @@ const traverseDirectory = async (baseUri, currentPath, onEntry, visited = new Se
|
|
|
1416
1424
|
}
|
|
1417
1425
|
visited.add(uri);
|
|
1418
1426
|
try {
|
|
1419
|
-
const entries = await
|
|
1427
|
+
const entries = await readDirWithFileTypes(uri);
|
|
1420
1428
|
for (const entry of entries) {
|
|
1421
1429
|
const entryPath = currentPath === '' ? entry.name : `${currentPath}/${entry.name}`;
|
|
1422
1430
|
await onEntry(entryPath, entry);
|
|
1423
|
-
if (entry.
|
|
1431
|
+
if (entry.type === Directory && !shouldExcludeDir(entry.name)) {
|
|
1424
1432
|
await traverseDirectory(baseUri, entryPath, onEntry, visited);
|
|
1425
1433
|
}
|
|
1426
1434
|
}
|
|
1427
|
-
} catch {
|
|
1435
|
+
} catch (error) {
|
|
1436
|
+
if (currentPath === '') {
|
|
1437
|
+
throw error;
|
|
1438
|
+
}
|
|
1428
1439
|
// Ignore unreadable directories and continue with other matches.
|
|
1429
1440
|
}
|
|
1430
1441
|
};
|
|
1431
1442
|
|
|
1432
1443
|
const MULTIPLE_SLASHES_REGEX = /\/+/g;
|
|
1433
1444
|
const LEADING_DOT_SLASH_REGEX = /^\.\//g;
|
|
1445
|
+
const PLACEHOLDER_WORKSPACE_URI = 'file:///workspace';
|
|
1434
1446
|
const hasGlobCharacters = part => {
|
|
1435
1447
|
return part.includes('*') || part.includes('?') || part.includes('[');
|
|
1436
1448
|
};
|
|
@@ -1459,6 +1471,12 @@ const normalizePattern = pattern => {
|
|
|
1459
1471
|
matchDirectories
|
|
1460
1472
|
};
|
|
1461
1473
|
};
|
|
1474
|
+
const joinUri = (baseUri, path) => {
|
|
1475
|
+
if (!path) {
|
|
1476
|
+
return baseUri;
|
|
1477
|
+
}
|
|
1478
|
+
return baseUri.endsWith('/') ? `${baseUri}${path}` : `${baseUri}/${path}`;
|
|
1479
|
+
};
|
|
1462
1480
|
const executeGlobTool = async (args, _options) => {
|
|
1463
1481
|
const pattern = typeof args.pattern === 'string' ? args.pattern : '';
|
|
1464
1482
|
if (!pattern) {
|
|
@@ -1466,26 +1484,37 @@ const executeGlobTool = async (args, _options) => {
|
|
|
1466
1484
|
error: 'Invalid argument: pattern must be a non-empty string.'
|
|
1467
1485
|
};
|
|
1468
1486
|
}
|
|
1487
|
+
const baseUri = typeof args.baseUri === 'string' ? args.baseUri : '';
|
|
1488
|
+
if (!baseUri || !isAbsoluteUri(baseUri)) {
|
|
1489
|
+
return {
|
|
1490
|
+
error: 'Invalid argument: baseUri must be an absolute URI.'
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
if (baseUri === PLACEHOLDER_WORKSPACE_URI || baseUri.startsWith(`${PLACEHOLDER_WORKSPACE_URI}/`)) {
|
|
1494
|
+
return {
|
|
1495
|
+
baseUri,
|
|
1496
|
+
error: 'Invalid argument: baseUri must be a real workspace folder URI. Call getWorkspaceUri first and use the returned workspaceUri value.'
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1469
1499
|
const normalizedPattern = normalizeInputPattern(pattern);
|
|
1470
1500
|
const {
|
|
1471
1501
|
baseDir,
|
|
1472
1502
|
globPart,
|
|
1473
1503
|
matchDirectories
|
|
1474
1504
|
} = normalizePattern(pattern);
|
|
1475
|
-
const baseUri = 'file:///workspace';
|
|
1476
1505
|
const matches = [];
|
|
1477
1506
|
try {
|
|
1478
1507
|
if (matchDirectories) {
|
|
1479
|
-
const dirUri =
|
|
1480
|
-
const entries = await
|
|
1508
|
+
const dirUri = joinUri(baseUri, globPart);
|
|
1509
|
+
const entries = await readDirWithFileTypes(dirUri);
|
|
1481
1510
|
for (const entry of entries) {
|
|
1482
1511
|
matches.push(globPart ? `${globPart}/${entry.name}` : entry.name);
|
|
1483
1512
|
}
|
|
1484
1513
|
} else if (globPart.includes('**')) {
|
|
1485
|
-
const baseDirUri =
|
|
1514
|
+
const baseDirUri = joinUri(baseUri, baseDir);
|
|
1486
1515
|
const visited = new Set();
|
|
1487
1516
|
await traverseDirectory(baseDirUri, '', async (relativePath, entry) => {
|
|
1488
|
-
if (
|
|
1517
|
+
if (entry.type !== File) {
|
|
1489
1518
|
return;
|
|
1490
1519
|
}
|
|
1491
1520
|
const fullPath = baseDir ? `${baseDir}/${relativePath}` : relativePath;
|
|
@@ -1494,8 +1523,8 @@ const executeGlobTool = async (args, _options) => {
|
|
|
1494
1523
|
}
|
|
1495
1524
|
}, visited);
|
|
1496
1525
|
} else {
|
|
1497
|
-
const dirUri =
|
|
1498
|
-
const entries = await
|
|
1526
|
+
const dirUri = joinUri(baseUri, baseDir);
|
|
1527
|
+
const entries = await readDirWithFileTypes(dirUri);
|
|
1499
1528
|
for (const entry of entries) {
|
|
1500
1529
|
const fullPath = baseDir ? `${baseDir}/${entry.name}` : entry.name;
|
|
1501
1530
|
if (matchesGlobPattern(fullPath, normalizedPattern)) {
|
|
@@ -1727,6 +1756,22 @@ const executeGrepSearchTool = async (args, options) => {
|
|
|
1727
1756
|
}
|
|
1728
1757
|
};
|
|
1729
1758
|
|
|
1759
|
+
const getEntryType = type => {
|
|
1760
|
+
switch (type) {
|
|
1761
|
+
case Directory:
|
|
1762
|
+
return 'folder';
|
|
1763
|
+
case File:
|
|
1764
|
+
return 'file';
|
|
1765
|
+
case Symlink:
|
|
1766
|
+
return 'symlink';
|
|
1767
|
+
default:
|
|
1768
|
+
return 'unknown';
|
|
1769
|
+
}
|
|
1770
|
+
};
|
|
1771
|
+
const mapEntry = entry => ({
|
|
1772
|
+
name: entry.name,
|
|
1773
|
+
type: getEntryType(entry.type)
|
|
1774
|
+
});
|
|
1730
1775
|
const executeListFilesTool = async (args, _options) => {
|
|
1731
1776
|
const uri = typeof args.uri === 'string' ? args.uri : '';
|
|
1732
1777
|
if (!uri || !isAbsoluteUri(uri)) {
|
|
@@ -1743,7 +1788,7 @@ const executeListFilesTool = async (args, _options) => {
|
|
|
1743
1788
|
try {
|
|
1744
1789
|
const entries = await invoke('FileSystem.readDirWithFileTypes', uri);
|
|
1745
1790
|
return {
|
|
1746
|
-
entries,
|
|
1791
|
+
entries: entries.map(mapEntry),
|
|
1747
1792
|
uri
|
|
1748
1793
|
};
|
|
1749
1794
|
} catch (error) {
|
|
@@ -2295,17 +2340,21 @@ const getGetWorkspaceUriTool = () => {
|
|
|
2295
2340
|
const getGlobTool = () => {
|
|
2296
2341
|
return {
|
|
2297
2342
|
function: {
|
|
2298
|
-
description: 'Find files by glob pattern and return matching relative paths.',
|
|
2343
|
+
description: 'Find files by glob pattern under a specific workspace folder URI and return matching relative paths. If you do not already have a real workspace URI, call getWorkspaceUri first and then pass that returned workspaceUri as baseUri.',
|
|
2299
2344
|
name: 'glob',
|
|
2300
2345
|
parameters: {
|
|
2301
2346
|
additionalProperties: false,
|
|
2302
2347
|
properties: {
|
|
2348
|
+
baseUri: {
|
|
2349
|
+
description: 'Absolute folder URI for the workspace root or subfolder where the glob search should start. If unknown, call getWorkspaceUri first and pass the returned workspaceUri value.',
|
|
2350
|
+
type: 'string'
|
|
2351
|
+
},
|
|
2303
2352
|
pattern: {
|
|
2304
2353
|
description: 'Glob pattern to match files, for example `packages/e2e/src/*.ts`.',
|
|
2305
2354
|
type: 'string'
|
|
2306
2355
|
}
|
|
2307
2356
|
},
|
|
2308
|
-
required: ['pattern'],
|
|
2357
|
+
required: ['baseUri', 'pattern'],
|
|
2309
2358
|
type: 'object'
|
|
2310
2359
|
}
|
|
2311
2360
|
},
|