@lvce-editor/chat-tool-worker 7.13.0 → 8.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.
@@ -1431,6 +1431,7 @@ const traverseDirectory = async (baseUri, currentPath, onEntry, visited = new Se
1431
1431
 
1432
1432
  const MULTIPLE_SLASHES_REGEX = /\/+/g;
1433
1433
  const LEADING_DOT_SLASH_REGEX = /^\.\//g;
1434
+ const PLACEHOLDER_WORKSPACE_URI = 'file:///workspace';
1434
1435
  const hasGlobCharacters = part => {
1435
1436
  return part.includes('*') || part.includes('?') || part.includes('[');
1436
1437
  };
@@ -1459,6 +1460,12 @@ const normalizePattern = pattern => {
1459
1460
  matchDirectories
1460
1461
  };
1461
1462
  };
1463
+ const joinUri = (baseUri, path) => {
1464
+ if (!path) {
1465
+ return baseUri;
1466
+ }
1467
+ return baseUri.endsWith('/') ? `${baseUri}${path}` : `${baseUri}/${path}`;
1468
+ };
1462
1469
  const executeGlobTool = async (args, _options) => {
1463
1470
  const pattern = typeof args.pattern === 'string' ? args.pattern : '';
1464
1471
  if (!pattern) {
@@ -1466,23 +1473,34 @@ const executeGlobTool = async (args, _options) => {
1466
1473
  error: 'Invalid argument: pattern must be a non-empty string.'
1467
1474
  };
1468
1475
  }
1476
+ const baseUri = typeof args.baseUri === 'string' ? args.baseUri : '';
1477
+ if (!baseUri || !isAbsoluteUri(baseUri)) {
1478
+ return {
1479
+ error: 'Invalid argument: baseUri must be an absolute URI.'
1480
+ };
1481
+ }
1482
+ if (baseUri === PLACEHOLDER_WORKSPACE_URI || baseUri.startsWith(`${PLACEHOLDER_WORKSPACE_URI}/`)) {
1483
+ return {
1484
+ baseUri,
1485
+ error: 'Invalid argument: baseUri must be a real workspace folder URI. Call getWorkspaceUri first and use the returned workspaceUri value.'
1486
+ };
1487
+ }
1469
1488
  const normalizedPattern = normalizeInputPattern(pattern);
1470
1489
  const {
1471
1490
  baseDir,
1472
1491
  globPart,
1473
1492
  matchDirectories
1474
1493
  } = normalizePattern(pattern);
1475
- const baseUri = 'file:///workspace';
1476
1494
  const matches = [];
1477
1495
  try {
1478
1496
  if (matchDirectories) {
1479
- const dirUri = globPart ? `${baseUri}/${globPart}` : baseUri;
1497
+ const dirUri = joinUri(baseUri, globPart);
1480
1498
  const entries = await invoke('FileSystem.readDirWithFileTypes', dirUri);
1481
1499
  for (const entry of entries) {
1482
1500
  matches.push(globPart ? `${globPart}/${entry.name}` : entry.name);
1483
1501
  }
1484
1502
  } else if (globPart.includes('**')) {
1485
- const baseDirUri = baseDir ? `${baseUri}/${baseDir}` : baseUri;
1503
+ const baseDirUri = joinUri(baseUri, baseDir);
1486
1504
  const visited = new Set();
1487
1505
  await traverseDirectory(baseDirUri, '', async (relativePath, entry) => {
1488
1506
  if (!entry.isFile()) {
@@ -1494,7 +1512,7 @@ const executeGlobTool = async (args, _options) => {
1494
1512
  }
1495
1513
  }, visited);
1496
1514
  } else {
1497
- const dirUri = baseDir ? `${baseUri}/${baseDir}` : baseUri;
1515
+ const dirUri = joinUri(baseUri, baseDir);
1498
1516
  const entries = await invoke('FileSystem.readDirWithFileTypes', dirUri);
1499
1517
  for (const entry of entries) {
1500
1518
  const fullPath = baseDir ? `${baseDir}/${entry.name}` : entry.name;
@@ -2295,17 +2313,21 @@ const getGetWorkspaceUriTool = () => {
2295
2313
  const getGlobTool = () => {
2296
2314
  return {
2297
2315
  function: {
2298
- description: 'Find files by glob pattern and return matching relative paths.',
2316
+ 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
2317
  name: 'glob',
2300
2318
  parameters: {
2301
2319
  additionalProperties: false,
2302
2320
  properties: {
2321
+ baseUri: {
2322
+ 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.',
2323
+ type: 'string'
2324
+ },
2303
2325
  pattern: {
2304
2326
  description: 'Glob pattern to match files, for example `packages/e2e/src/*.ts`.',
2305
2327
  type: 'string'
2306
2328
  }
2307
2329
  },
2308
- required: ['pattern'],
2330
+ required: ['baseUri', 'pattern'],
2309
2331
  type: 'object'
2310
2332
  }
2311
2333
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/chat-tool-worker",
3
- "version": "7.13.0",
3
+ "version": "8.0.0",
4
4
  "description": "Chat Tool Worker",
5
5
  "repository": {
6
6
  "type": "git",