Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance workspace.findFiles to Support Absolute Paths with Ignore Patterns #989

Open
anrgct opened this issue Jan 8, 2025 · 2 comments
Open

Comments

@anrgct
Copy link

anrgct commented Jan 8, 2025

Does workspace.findFiles not support absolute paths? Can the API be modified to support absolute paths while also allowing the input of ignore patterns? This method is very convenient for retrieving files.

const allFiles = await workspace.findFiles("/Users/anrgct/workspace/genaiscript/packages/sample/genaisrc/samples/**/*.{js,mjs,ts,mts}")
// path should be a `path.relative()`d string, but got "/Users/anrgct/workspace/genaiscript/packages/cli/src/worker.ts"
Copy link

github-actions bot commented Jan 8, 2025

@username

The current implementation of workspace.findFiles indeed expects relative paths rather than absolute paths, which can be limiting when dealing with deep directory structures.

To address this need, we could enhance the API to accept both relative and absolute paths. Additionally, it would be beneficial to include support for ignore patterns to filter out unwanted files or directories during the search.

Here’s a potential enhancement:

const allFiles = await workspace.findFiles(
  {
    "include": "/Users/anrgct/workspace/genaiscript/packages/sample/genaisrc/samples/**/*.{js,mjs,ts,mts}",
    "ignore": "**/.git/**,**/node_modules/**"
  }
);

This revised method would allow you to specify both include and ignore patterns and could handle absolute paths seamlessly. We should also ensure that the documentation reflects these changes clearly.

Thoughts?

AI-generated content by issue-reviewer may be incorrect

@pelikhan
Copy link
Member

pelikhan commented Jan 8, 2025

The limitation to relative files is technical debt from when we ran inside VSCode using the virtualized workspace file system; there's no real reason to be limited to relative paths anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants