@lvce-editor/chat-tool-worker 8.3.0 → 8.4.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.
@@ -1426,27 +1426,31 @@ const DEFAULT_EXCLUDE_DIRS = new Set(['.git', 'node_modules', '.cache', '.venv',
1426
1426
  const shouldExcludeDir = dirName => {
1427
1427
  return DEFAULT_EXCLUDE_DIRS.has(dirName);
1428
1428
  };
1429
- const traverseDirectory = async (baseUri, currentPath, onEntry, visited = new Set()) => {
1430
- const uri = currentPath === '' ? baseUri : `${baseUri}/${currentPath}`;
1431
- if (visited.has(uri)) {
1432
- return;
1433
- }
1434
- visited.add(uri);
1435
- try {
1436
- const entries = await readDirWithFileTypes(uri);
1437
- for (const entry of entries) {
1438
- const entryPath = currentPath === '' ? entry.name : `${currentPath}/${entry.name}`;
1439
- await onEntry(entryPath, entry);
1440
- if (entry.type === Directory && !shouldExcludeDir(entry.name)) {
1441
- await traverseDirectory(baseUri, entryPath, onEntry, visited);
1442
- }
1429
+ const traverseDirectory = async (baseUri, currentPath, onEntry) => {
1430
+ const visited = new Set();
1431
+ const visit = async path => {
1432
+ const uri = path === '' ? baseUri : `${baseUri}/${path}`;
1433
+ if (visited.has(uri)) {
1434
+ return;
1443
1435
  }
1444
- } catch (error) {
1445
- if (currentPath === '') {
1446
- throw error;
1436
+ visited.add(uri);
1437
+ try {
1438
+ const entries = await readDirWithFileTypes(uri);
1439
+ for (const entry of entries) {
1440
+ const entryPath = path === '' ? entry.name : `${path}/${entry.name}`;
1441
+ await onEntry(entryPath, entry);
1442
+ if (entry.type === Directory && !shouldExcludeDir(entry.name)) {
1443
+ await visit(entryPath);
1444
+ }
1445
+ }
1446
+ } catch (error) {
1447
+ if (path === '') {
1448
+ throw error;
1449
+ }
1450
+ // Ignore unreadable directories and continue with other matches.
1447
1451
  }
1448
- // Ignore unreadable directories and continue with other matches.
1449
- }
1452
+ };
1453
+ return visit(currentPath);
1450
1454
  };
1451
1455
 
1452
1456
  const MULTIPLE_SLASHES_REGEX = /\/+/g;
@@ -1521,7 +1525,6 @@ const executeGlobTool = async (args, _options) => {
1521
1525
  }
1522
1526
  } else if (globPart.includes('**')) {
1523
1527
  const baseDirUri = joinUri(baseUri, baseDir);
1524
- const visited = new Set();
1525
1528
  await traverseDirectory(baseDirUri, '', async (relativePath, entry) => {
1526
1529
  if (entry.type !== File) {
1527
1530
  return;
@@ -1530,7 +1533,7 @@ const executeGlobTool = async (args, _options) => {
1530
1533
  if (matchesGlobPattern(fullPath, normalizedPattern)) {
1531
1534
  matches.push(fullPath);
1532
1535
  }
1533
- }, visited);
1536
+ });
1534
1537
  } else {
1535
1538
  const dirUri = joinUri(baseUri, baseDir);
1536
1539
  const entries = await readDirWithFileTypes(dirUri);
@@ -2857,9 +2860,14 @@ const handleMessagePort = async port => {
2857
2860
  });
2858
2861
  };
2859
2862
 
2863
+ const initialize = async () => {
2864
+ // TODO
2865
+ };
2866
+
2860
2867
  const commandMap = {
2861
2868
  'ChatTool.execute': executeChatTool,
2862
2869
  'ChatTool.getTools': getBasicChatTools,
2870
+ 'ChatTool.initialize': initialize,
2863
2871
  'HandleMessagePort.handleMessagePort': handleMessagePort
2864
2872
  };
2865
2873
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/chat-tool-worker",
3
- "version": "8.3.0",
3
+ "version": "8.4.0",
4
4
  "description": "Chat Tool Worker",
5
5
  "repository": {
6
6
  "type": "git",